]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- add literal_binds for delete() statements in addition to insert()/update()
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Feb 2016 16:07:44 +0000 (11:07 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 3 Feb 2016 16:10:40 +0000 (11:10 -0500)
- move tests to CRUDTest
- changelog, fixes #3643

(cherry picked from commit 150591f9e0a94902cb2a76b68ac7c9d8a1a3ec83)

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/sql/compiler.py
test/sql/test_compiler.py

index 15996be21ec0928be246501409608fc4df213f45..6130fdcefc2e78a1fe051fe9568f443af5e97a64 100644 (file)
     :version: 1.0.12
     :released:
 
+    .. change::
+        :tags: bug, sql
+        :tickets: 3643
+        :pullreq: github:232
+
+        Fixed issue where the "literal_binds" flag was not propagated
+        for :func:`.expression.insert`, :func:`.expression.update` or
+        :func:`.expression.delete` constructs when compiled to string
+        SQL.  Pull request courtesy Tim Tate.
+
     .. change::
         :tags: bug, oracle, jython
         :tickets: 3621
index ec16511f1008a2d7c60836cf45cabb47a9369c4d..0a824b4666cc1a622e522697b26c049842acf5d9 100644 (file)
@@ -2067,7 +2067,7 @@ class SQLCompiler(Compiled):
                     delete_stmt, delete_stmt._returning)
 
         if delete_stmt._whereclause is not None:
-            t = delete_stmt._whereclause._compiler_dispatch(self)
+            t = delete_stmt._whereclause._compiler_dispatch(self, **kw)
             if t:
                 text += " WHERE " + t
 
index 978547fd76bd4e6ecf4b1dd10991bfab20cd2b4f..026daa562b08c1743510995295290bf0c865dc85 100644 (file)
@@ -254,22 +254,6 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL):
             literal_binds=True
         )
 
-    def test_insert_literal_binds(self):
-        stmt = table1.insert().values(myid=3, name='jack')
-
-        self.assert_compile(
-            stmt,
-            "INSERT INTO mytable (myid, name) VALUES (3, 'jack')",
-            literal_binds=True)
-
-    def test_update_literal_binds(self):
-        stmt = table1.update().values(name='jack').where(table1.c.name == 'jill')
-
-        self.assert_compile(
-            stmt,
-            "UPDATE mytable SET name='jack' WHERE mytable.name = 'jill'",
-            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)
@@ -2606,6 +2590,31 @@ class KwargPropagationTest(fixtures.TestBase):
 class CRUDTest(fixtures.TestBase, AssertsCompiledSQL):
     __dialect__ = 'default'
 
+    def test_insert_literal_binds(self):
+        stmt = table1.insert().values(myid=3, name='jack')
+
+        self.assert_compile(
+            stmt,
+            "INSERT INTO mytable (myid, name) VALUES (3, 'jack')",
+            literal_binds=True)
+
+    def test_update_literal_binds(self):
+        stmt = table1.update().values(name='jack').\
+            where(table1.c.name == 'jill')
+
+        self.assert_compile(
+            stmt,
+            "UPDATE mytable SET name='jack' WHERE mytable.name = 'jill'",
+            literal_binds=True)
+
+    def test_delete_literal_binds(self):
+        stmt = table1.delete().where(table1.c.name == 'jill')
+
+        self.assert_compile(
+            stmt,
+            "DELETE FROM mytable WHERE mytable.name = 'jill'",
+            literal_binds=True)
+
     def test_correlated_update(self):
         # test against a straight text subquery
         u = update(