]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed support for "literal_binds" mode when using limit/offset
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 23 Apr 2015 16:05:30 +0000 (12:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 23 Apr 2015 16:07:56 +0000 (12:07 -0400)
with Firebird, so that the values are again rendered inline when
this is selected.  Related to :ticket:`3034`.
fixes #3381

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/dialects/firebird/base.py
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/dialects/sybase/base.py
lib/sqlalchemy/sql/compiler.py
test/requirements.py
test/sql/test_compiler.py

index 45aef66f0fbd6c4309d3a876be1d0ef113091f00..f55a8f2a5e34ae4d9af57064acb73c7eb5af8219 100644 (file)
         clauses were not properly interpreted by the Firebird dialect.
         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
index 14e8165c14dbf2ecbacd087311f57822677529e4..e407e2f255f20c449a03e321b32549c1fa7723c3 100644 (file)
@@ -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 ""
index 26b7947120f2007b1879106533c0c0878c57277c..522e59b00df54d56c06bc7be7354cee5fc275b4e 100644 (file)
@@ -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
index 8460ff92aeaef848a8aa5da47053490d71b394ce..fee05fd2d5587c32283ed1443111681a413eb688 100644 (file)
@@ -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::
index c1c0ab08e4076cfd1a4ca0dab43f18d500606bde..73fe5022a5601128eab3b30b28df7196a513f5d1 100644 (file)
@@ -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 ""
 
index 57213382ea453bb9b7b50d818ceecd8a2b437be3..1baab6db4ab559e945907add2e71c882988c53ca 100644 (file)
@@ -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
index 5633159cdc9f3471fd5f799ddd6593b9bb363b1a..91b677a0efc4850f8db1ca692bf630eecb7628c0 100644 (file)
@@ -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.
 
index 3ed6bea4da54a9476b80c20225db141c4fbcb218..77d941a67103590e56e4b9a760cc1cd0e1ac725d 100644 (file)
@@ -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
index 75f9a7c82c38b02fe5251d7ddd88c71dd9e490f0..03646d78d5badcef4a359e8fe7987787837c644c 100644 (file)
@@ -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):