diff options
Diffstat (limited to 'lib/sqlalchemy/ansisql.py')
-rw-r--r-- | lib/sqlalchemy/ansisql.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ansisql.py b/lib/sqlalchemy/ansisql.py index 691106a71..79215dec7 100644 --- a/lib/sqlalchemy/ansisql.py +++ b/lib/sqlalchemy/ansisql.py @@ -269,7 +269,12 @@ class ANSICompiler(sql.Compiled): t = self.get_str(select.having) if t: text += " \nHAVING " + t - + + if select.limit is not None or select.offset is not None: + # TODO: ok, so this is a simple limit/offset thing. + # need to make this DB neutral for mysql, oracle + text += self.limit_clause(select) + if getattr(select, 'issubquery', False): self.strings[select] = "(" + text + ")" else: @@ -277,6 +282,14 @@ class ANSICompiler(sql.Compiled): self.froms[select] = "(" + text + ")" + def limit_clause(self, select): + if select.limit is not None: + return " \n LIMIT " + str(select.limit) + if select.offset is not None: + if select.limit is None: + return " \n LIMIT -1" + return " OFFSET " + str(select.offset) + def visit_table(self, table): self.froms[table] = table.fullname self.strings[table] = "" |