1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-02 20:15:26 +02:00

Make storage providers generate row limit clause

This commit is contained in:
Harvey Kandola 2019-04-04 12:08:57 +01:00
parent 8515a77403
commit 2ddd7ada9b
5 changed files with 36 additions and 0 deletions

View file

@ -119,3 +119,21 @@ func (c *Context) IsTrue() string {
func (c *Context) IsFalse() string {
return c.Runtime.StoreProvider.IsFalse()
}
// RowLimitVariants returns the SQL clause for limiting rows.
// Depending on the storage provider, the limit clause goes either
// at the start of the query or the end.
func (c *Context) RowLimitVariants(max int) (variantStart string, variantEnd string) {
variantStart = ""
variantEnd = ""
if c.Runtime.StoreProvider.Type() == env.StoreTypeSQLServer {
// SQL Server and variants use 'SELECT TOP nnn' syntax.
variantStart = c.Runtime.StoreProvider.RowLimit(max)
} else {
// MySQL and variants use 'SELECT ... LIMIT nnn' syntax.
variantEnd = c.Runtime.StoreProvider.RowLimit(max)
}
return
}