summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-04-23 12:05:30 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-04-23 12:07:56 -0400
commitdd4240e43b4138aeca41c393c3f97ae2e60b7c79 (patch)
tree4bb21765f6fb0e1e217f3d29dfb0d2aea0ce7b17
parent167a45a442a2551400af0b102b590e70267e9b77 (diff)
downloadsqlalchemy-dd4240e43b4138aeca41c393c3f97ae2e60b7c79.tar.gz
- Fixed support for "literal_binds" mode when using limit/offset
with Firebird, so that the values are again rendered inline when this is selected. Related to :ticket:`3034`. fixes #3381
-rw-r--r--doc/build/changelog/changelog_10.rst8
-rw-r--r--lib/sqlalchemy/dialects/firebird/base.py8
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py5
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py2
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py5
-rw-r--r--lib/sqlalchemy/dialects/sybase/base.py2
-rw-r--r--lib/sqlalchemy/sql/compiler.py4
-rw-r--r--test/requirements.py2
-rw-r--r--test/sql/test_compiler.py6
9 files changed, 26 insertions, 16 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 45aef66f0..f55a8f2a5 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -28,6 +28,14 @@
Pull request courtesy effem-git.
.. change::
+ :tags: bug, firebird
+ :tickets: 3381
+
+ Fixed support for "literal_binds" mode when using limit/offset
+ with Firebird, so that the values are again rendered inline when
+ this is selected. Related to :ticket:`3034`.
+
+ .. change::
:tags: bug, sqlite
:tickets: 3378
diff --git a/lib/sqlalchemy/dialects/firebird/base.py b/lib/sqlalchemy/dialects/firebird/base.py
index 14e8165c1..e407e2f25 100644
--- a/lib/sqlalchemy/dialects/firebird/base.py
+++ b/lib/sqlalchemy/dialects/firebird/base.py
@@ -293,7 +293,7 @@ class FBCompiler(sql.compiler.SQLCompiler):
def visit_sequence(self, seq):
return "gen_id(%s, 1)" % self.preparer.format_sequence(seq)
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
"""Called when building a ``SELECT`` statement, position is just
before column list Firebird puts the limit and offset right
after the ``SELECT``...
@@ -301,14 +301,14 @@ class FBCompiler(sql.compiler.SQLCompiler):
result = ""
if select._limit_clause is not None:
- result += "FIRST %s " % self.process(select._limit_clause)
+ result += "FIRST %s " % self.process(select._limit_clause, **kw)
if select._offset_clause is not None:
- result += "SKIP %s " % self.process(select._offset_clause)
+ result += "SKIP %s " % self.process(select._offset_clause, **kw)
if select._distinct:
result += "DISTINCT "
return result
- def limit_clause(self, select):
+ def limit_clause(self, select, **kw):
"""Already taken care of in the `get_select_precolumns` method."""
return ""
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index 26b794712..522e59b00 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -979,7 +979,7 @@ class MSSQLCompiler(compiler.SQLCompiler):
self.process(binary.left, **kw),
self.process(binary.right, **kw))
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
""" MS-SQL puts TOP, it's version of LIMIT here """
s = ""
@@ -995,7 +995,8 @@ class MSSQLCompiler(compiler.SQLCompiler):
if s:
return s
else:
- return compiler.SQLCompiler.get_select_precolumns(self, select)
+ return compiler.SQLCompiler.get_select_precolumns(
+ self, select, **kw)
def get_from_hint_text(self, table, text):
return text
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index 8460ff92a..fee05fd2d 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -1829,7 +1829,7 @@ class MySQLCompiler(compiler.SQLCompiler):
def visit_false(self, element, **kw):
return "false"
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
"""Add special MySQL keywords in place of DISTINCT.
.. note::
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index c1c0ab08e..73fe5022a 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1446,7 +1446,7 @@ class PGCompiler(compiler.SQLCompiler):
raise exc.CompileError("Unrecognized hint: %r" % hint)
return "ONLY " + sqltext
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
if select._distinct is not False:
if select._distinct is True:
return "DISTINCT "
@@ -1455,7 +1455,8 @@ class PGCompiler(compiler.SQLCompiler):
[self.process(col) for col in select._distinct]
) + ") "
else:
- return "DISTINCT ON (" + self.process(select._distinct) + ") "
+ return "DISTINCT ON (" + \
+ self.process(select._distinct, **kw) + ") "
else:
return ""
diff --git a/lib/sqlalchemy/dialects/sybase/base.py b/lib/sqlalchemy/dialects/sybase/base.py
index 57213382e..1baab6db4 100644
--- a/lib/sqlalchemy/dialects/sybase/base.py
+++ b/lib/sqlalchemy/dialects/sybase/base.py
@@ -323,7 +323,7 @@ class SybaseSQLCompiler(compiler.SQLCompiler):
'milliseconds': 'millisecond'
})
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
s = select._distinct and "DISTINCT " or ""
# TODO: don't think Sybase supports
# bind params for FIRST / TOP
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 5633159cd..91b677a0e 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -1568,7 +1568,7 @@ class SQLCompiler(Compiled):
text += self._generate_prefixes(
select, select._prefixes, **kwargs)
- text += self.get_select_precolumns(select)
+ text += self.get_select_precolumns(select, **kwargs)
# the actual list of columns to print in the SELECT column list.
inner_columns = [
@@ -1742,7 +1742,7 @@ class SQLCompiler(Compiled):
else:
return "WITH"
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
"""Called when building a ``SELECT`` statement, position is just
before column list.
diff --git a/test/requirements.py b/test/requirements.py
index 3ed6bea4d..77d941a67 100644
--- a/test/requirements.py
+++ b/test/requirements.py
@@ -130,7 +130,7 @@ class DefaultRequirements(SuiteRequirements):
def temporary_tables(self):
"""target database supports temporary tables"""
return skip_if(
- ["mssql"], "sql server has some other syntax?"
+ ["mssql", "firebird"], "not supported (?)"
)
@property
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py
index 75f9a7c82..03646d78d 100644
--- a/test/sql/test_compiler.py
+++ b/test/sql/test_compiler.py
@@ -260,16 +260,16 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
class MyCompiler(compiler.SQLCompiler):
- def get_select_precolumns(self, select):
+ def get_select_precolumns(self, select, **kw):
result = ""
if select._limit:
result += "FIRST %s " % self.process(
literal(
- select._limit))
+ select._limit), **kw)
if select._offset:
result += "SKIP %s " % self.process(
literal(
- select._offset))
+ select._offset), **kw)
return result
def limit_clause(self, select, **kw):