summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_compiler.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-10-17 11:07:14 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-10-17 12:14:41 -0400
commitf917b353e88aa11d0efff1dc8bf1dbd079d57efb (patch)
tree8ee2d25278b63f8009cbd77a9a53da1770330567 /test/dialect/postgresql/test_compiler.py
parent8ef4f6a53864ce9c57c4879d6b2aa0f81ddbf596 (diff)
downloadsqlalchemy-f917b353e88aa11d0efff1dc8bf1dbd079d57efb.tar.gz
Add a qualifying character to multi INSERT..VALUES parameter names
Changed the naming convention used when generating bound parameters for a multi-VALUES insert statement, so that the numbered parameter names don't conflict with the anonymized parameters of a WHERE clause, as is now common in a PostgreSQL ON CONFLICT construct. Change-Id: I3188d100fe4d322a47d344d6a63d3e40b915f228 Fixes: #3828
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
-rw-r--r--test/dialect/postgresql/test_compiler.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py
index ac8bb4815..52dd699fc 100644
--- a/test/dialect/postgresql/test_compiler.py
+++ b/test/dialect/postgresql/test_compiler.py
@@ -1208,6 +1208,28 @@ class InsertOnConflictTest(fixtures.TestBase, AssertsCompiledSQL):
"WHERE mytable.name > %(name_1)s "
'DO UPDATE SET name = excluded.name')
+ def test_do_update_index_elements_where_target_multivalues(self):
+ i = insert(
+ self.table1,
+ values=[dict(name='foo'), dict(name='bar'), dict(name='bat')])
+ i = i.on_conflict_do_update(
+ index_elements=self.goofy_index.expressions,
+ index_where=self.goofy_index.dialect_options[
+ 'postgresql']['where'],
+ set_=dict(name=i.excluded.name)
+ )
+ self.assert_compile(
+ i,
+ "INSERT INTO mytable (name) "
+ "VALUES (%(name_m0)s), (%(name_m1)s), (%(name_m2)s) "
+ "ON CONFLICT (name) "
+ "WHERE mytable.name > %(name_1)s "
+ "DO UPDATE SET name = excluded.name",
+ checkparams={
+ 'name_1': 'm', 'name_m0': 'foo',
+ 'name_m1': 'bar', 'name_m2': 'bat'}
+ )
+
def test_do_update_unnamed_index_target(self):
i = insert(
self.table1, values=dict(name='foo'))