From f917b353e88aa11d0efff1dc8bf1dbd079d57efb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 17 Oct 2016 11:07:14 -0400 Subject: 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 --- test/dialect/postgresql/test_compiler.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/dialect/postgresql/test_compiler.py') 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')) -- cgit v1.2.1