summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authorDobes Vandermeer <dvandermeer@roovy.com>2014-04-25 10:42:12 -0700
committerDobes Vandermeer <dvandermeer@roovy.com>2014-04-25 10:42:12 -0700
commit4af172b644d90f1bcab3de2bd0501a9cf50dc1d5 (patch)
tree7aba558ad48bee120a64a8350e6a515cdca7b3d2 /lib/sqlalchemy/dialects
parente9b398f8a6ecd5b68142ab334a81683eff966e09 (diff)
downloadsqlalchemy-4af172b644d90f1bcab3de2bd0501a9cf50dc1d5.tar.gz
Use _offset_clause and _limit_clause, which are always Visitable and usually a BindParameter, instead of _offset and _limit in GenerativeSelect.
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/firebird/base.py8
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py7
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py16
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py10
-rw-r--r--lib/sqlalchemy/dialects/sqlite/base.py10
5 files changed, 26 insertions, 25 deletions
diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py
index fdadb61c1..431a16a6e 100644
--- a/lib/sqlalchemy/dialects/firebird/base.py
+++ b/lib/sqlalchemy/dialects/firebird/base.py
@@ -300,10 +300,10 @@ class FBCompiler(sql.compiler.SQLCompiler):
"""
result = ""
- if select._limit:
- result += "FIRST %s " % self.process(_literal_as_binds(select._limit))
- if select._offset:
- result += "SKIP %s " % self.process(_literal_as_binds(select._offset))
+ if select._limit_clause:
+ result += "FIRST %s " % self.process(select._limit_clause)
+ if select._offset_clause:
+ result += "SKIP %s " % self.process(select._offset_clause)
if select._distinct:
result += "DISTINCT "
return result
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 9a8cddd98..6a13d1dca 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -741,15 +741,16 @@ class MSSQLCompiler(compiler.SQLCompiler):
def get_select_precolumns(self, select):
""" MS-SQL puts TOP, it's version of LIMIT here """
- if select._distinct or select._limit is not None:
+ limit = select._limit
+ if select._distinct or limit is not None:
s = select._distinct and "DISTINCT " or ""
# ODBC drivers and possibly others
# don't support bind params in the SELECT clause on SQL Server.
# so have to use literal here.
- if select._limit is not None:
+ if limit is not None:
if not select._offset:
- s += "TOP %d " % select._limit
+ s += "TOP %d " % limit
return s
return compiler.SQLCompiler.get_select_precolumns(self, select)
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index ba6e7b625..4ad45f935 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1568,15 +1568,15 @@ class MySQLCompiler(compiler.SQLCompiler):
# The latter is more readable for offsets but we're stuck with the
# former until we can refine dialects by server revision.
- limit, offset = select._limit, select._offset
+ limit_clause, offset_clause = select._limit_clause, select._offset_clause
- if (limit, offset) == (None, None):
+ if (limit_clause, offset_clause) == (None, None):
return ''
- elif offset is not None:
+ elif offset_clause is not None:
# As suggested by the MySQL docs, need to apply an
# artificial limit if one wasn't provided
# http://dev.mysql.com/doc/refman/5.0/en/select.html
- if limit is None:
+ if limit_clause is None:
# hardwire the upper limit. Currently
# needed by OurSQL with Python 3
# (https://bugs.launchpad.net/oursql/+bug/686232),
@@ -1584,15 +1584,15 @@ class MySQLCompiler(compiler.SQLCompiler):
# bound as part of MySQL's "syntax" for OFFSET with
# no LIMIT
return ' \n LIMIT %s, %s' % (
- self.process(sql.literal(offset)),
+ self.process(offset_clause),
"18446744073709551615")
else:
return ' \n LIMIT %s, %s' % (
- self.process(sql.literal(offset)),
- self.process(sql.literal(limit)))
+ self.process(offset_clause),
+ self.process(limit_clause))
else:
# No offset provided, so just use the limit
- return ' \n LIMIT %s' % (self.process(sql.literal(limit)),)
+ return ' \n LIMIT %s' % (self.process(limit_clause),)
def update_limit_clause(self, update_stmt):
limit = update_stmt.kwargs.get('%s_limit' % self.dialect.name, None)
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index d63e3ed87..4e5f9d703 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1144,12 +1144,12 @@ class PGCompiler(compiler.SQLCompiler):
def limit_clause(self, select):
text = ""
- if select._limit is not None:
- text += " \n LIMIT " + self.process(_literal_as_binds(select._limit))
- if select._offset is not None:
- if select._limit is None:
+ if select._limit_clause is not None:
+ text += " \n LIMIT " + self.process(select._limit_clause)
+ if select._offset_clause is not None:
+ if select._limit_clause is None:
text += " \n LIMIT ALL"
- text += " OFFSET " + self.process(_literal_as_binds(select._offset))
+ text += " OFFSET " + self.process(select._offset_clause)
return text
def format_from_hint_text(self, sqltext, table, hint, iscrud):
diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py
index 1ae565232..02582709b 100644
--- a/lib/sqlalchemy/dialects/sqlite/base.py
+++ b/lib/sqlalchemy/dialects/sqlite/base.py
@@ -520,12 +520,12 @@ class SQLiteCompiler(compiler.SQLCompiler):
def limit_clause(self, select):
text = ""
- if select._limit is not None:
- text += "\n LIMIT " + self.process(_literal_as_binds(select._limit))
- if select._offset is not None:
- if select._limit is None:
+ if select._limit_clause is not None:
+ text += "\n LIMIT " + self.process(select._limit_clause)
+ if select._offset_clause is not None:
+ if select._limit_clause is None:
text += "\n LIMIT " + self.process(sql.literal(-1))
- text += " OFFSET " + self.process(_literal_as_binds(select._offset))
+ text += " OFFSET " + self.process(select._offset_clause)
else:
text += " OFFSET " + self.process(sql.literal(0))
return text