diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-12-07 01:37:55 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-12-07 01:37:55 +0000 |
commit | 44abaa9e567e6c412a2ce499907c65d97aa865dc (patch) | |
tree | 220c93883b683dcbaf2791a4caf269320abca1d1 /lib/sqlalchemy/ansisql.py | |
parent | 478b0e15ed70ae109e76b696efe151b7acac036b (diff) | |
download | sqlalchemy-44abaa9e567e6c412a2ce499907c65d97aa865dc.tar.gz |
added rudimentary support for limit and offset (with the hack version in oracle)
fixed up order_by to support a list/scalar of columns or asc/desc
fixed up query.py unit test
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] = "" |