]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- ensure kwargs are passed for limit clause on a compound select as well,
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 1 Nov 2014 00:00:42 +0000 (20:00 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 1 Nov 2014 00:00:42 +0000 (20:00 -0400)
further fixes for #3034

lib/sqlalchemy/sql/compiler.py
test/sql/test_compiler.py

index a6c30b7dc95158027d9e778a0b2daed9fc93e6b2..5fa78ad0f4a50e9674f0273d0c8605372aac6857 100644 (file)
@@ -813,7 +813,7 @@ class SQLCompiler(Compiled):
         text += self.order_by_clause(cs, **kwargs)
         text += (cs._limit_clause is not None
                  or cs._offset_clause is not None) and \
-            self.limit_clause(cs) or ""
+            self.limit_clause(cs, **kwargs) or ""
 
         if self.ctes and \
                 compound_index == 0 and toplevel:
index 3e6b873519c69823268e387223c351dfc06e2e54..bfafed599fd53cd5149fc25f47b7450d22a689e9 100644 (file)
@@ -238,6 +238,22 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
                 checkparams=params
             )
 
+    def test_limit_offset_select_literal_binds(self):
+        stmt = select([1]).limit(5).offset(6)
+        self.assert_compile(
+            stmt,
+            "SELECT 1 LIMIT 5 OFFSET 6",
+            literal_binds=True
+        )
+
+    def test_limit_offset_compound_select_literal_binds(self):
+        stmt = select([1]).union(select([2])).limit(5).offset(6)
+        self.assert_compile(
+            stmt,
+            "SELECT 1 UNION SELECT 2 LIMIT 5 OFFSET 6",
+            literal_binds=True
+        )
+
     def test_select_precol_compile_ordering(self):
         s1 = select([column('x')]).select_from(text('a')).limit(5).as_scalar()
         s2 = select([s1]).limit(10)