diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-12-28 16:32:53 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-01-09 17:37:25 -0500 |
commit | 4fec72f178f0da016301a0d12ad9abe02cc2b62a (patch) | |
tree | 1c5a203d309bb7162c5a844f7d5ad62ee94c071f | |
parent | e6eefc0c5e946f10cb31264d71d6f1987a3f96e8 (diff) | |
download | sqlalchemy-4fec72f178f0da016301a0d12ad9abe02cc2b62a.tar.gz |
Pass **kw to bound params in multi values
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
-rw-r--r-- | doc/build/changelog/changelog_11.rst | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/crud.py | 2 | ||||
-rw-r--r-- | test/sql/test_insert.py | 12 |
3 files changed, 21 insertions, 1 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index 1554987c1..704962e42 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -52,6 +52,14 @@ 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 diff --git a/lib/sqlalchemy/sql/crud.py b/lib/sqlalchemy/sql/crud.py index 42e22f93d..5739c22f9 100644 --- a/lib/sqlalchemy/sql/crud.py +++ b/lib/sqlalchemy/sql/crud.py @@ -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)) diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py index 73731e952..e23ab520d 100644 --- a/test/sql/test_insert.py +++ b/test/sql/test_insert.py @@ -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 |