]> 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:07:44 +0000 (11:07 -0500)
- move tests to CRUDTest
- changelog, fixes #3643

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 993956ef0cf2df50695e54aedf42f28406e02674..dbaa23a5d0fe1854d8125210e068c11293a19f19 100644 (file)
@@ -2094,7 +2094,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 00195c6bf6f765e415714d52a813868e5fa513bf..f11a4e61afd7471dbea904cfcad4cbe9412d9e2e 100644 (file)
@@ -255,22 +255,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)
@@ -2730,6 +2714,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(