]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Pass **kw to bound params in multi values
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Dec 2016 21:32:53 +0000 (16:32 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 9 Jan 2017 22:37:25 +0000 (17:37 -0500)
Fixed bug where literal_binds compiler flag was not honored by the
:class:`.Insert` construct for the "multiple values" feature; the
subsequent values are now rendered as literals.

Change-Id: I81ac358fd59995885d482e7571620090210865d2
Fixes: #3880
doc/build/changelog/changelog_11.rst
lib/sqlalchemy/sql/crud.py
test/sql/test_insert.py

index 1554987c10701aeb8dd392254be78289d13b75a7..704962e4237880d464311d3aea13bc0470a457e4 100644 (file)
         sqlalchemy.sql.expression, due to mis-spelled "any_" and "all_"
         functions.
 
+    .. change:: 3880
+        :tags: bg, sql
+        :tickets: 3880
+
+        Fixed bug where literal_binds compiler flag was not honored by the
+        :class:`.Insert` construct for the "multiple values" feature; the
+        subsequent values are now rendered as literals.
+
     .. change:: 3877
         :tags: bug, oracle, postgresql
         :tickets: 3877
index 42e22f93d0d8c59f428cce2b03a946aefb02a2f4..5739c22f9e52f84e79390501673895fc98c2cd05 100644 (file)
@@ -603,7 +603,7 @@ def _extend_values_for_multiparams(compiler, stmt, values, kw):
                 c,
                 (_create_bind_param(
                     compiler, c, row[c.key],
-                    name="%s_m%d" % (c.key, i + 1)
+                    name="%s_m%d" % (c.key, i + 1), **kw
                 ) if elements._is_literal(row[c.key])
                     else compiler.process(
                         row[c.key].self_group(), **kw))
index 73731e9527e46f70821d33b8059c4ae659d99d5f..e23ab520de994297d4bfd372273d51a07c65cd88 100644 (file)
@@ -683,6 +683,18 @@ class InsertImplicitReturningTest(
                 'othername_m0': 'foo'}
         )
 
+    def test_insert_multiple_values_literal_binds(self):
+        ins = self.tables.myothertable.insert().values([
+            {"othername": "foo"},
+            {"othername": "bar"},
+        ])
+        self.assert_compile(
+            ins,
+            "INSERT INTO myothertable (othername) VALUES ('foo'), ('bar')",
+            checkparams={},
+            literal_binds=True
+        )
+
     def test_insert_multiple_values_return_defaults(self):
         # TODO: not sure if this should raise an
         # error or what