summaryrefslogtreecommitdiff
path: root/test/sql/test_insert.py
diff options
context:
space:
mode:
authorAubrey Stark-Toller <aubrey@kleetope.net>2018-01-05 15:06:23 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2018-01-12 11:28:41 -0500
commitab2165e6d6e9b33f772e9eb3668b3e32175093c4 (patch)
tree4232c07f44de6422e9af5f2fbf7251c74b0ace49 /test/sql/test_insert.py
parent127ead7452f326509cde38fcf7c9f38f69d9ae0a (diff)
downloadsqlalchemy-ab2165e6d6e9b33f772e9eb3668b3e32175093c4.tar.gz
`ValuesBase.values` inconsistency fix
Fixed bug in :meth:`.Insert.values` where using the "multi-values" format in combination with :class:`.Column` objects as keys rather than strings would fail. Pull request courtesy Aubrey Stark-Toller. Change-Id: I9d3b40b5950df8f5bfdc8b1d22f9c3afb277f17f Pull-request: https://github.com/zzzeek/sqlalchemy/pull/412 Fixes: #4162
Diffstat (limited to 'test/sql/test_insert.py')
-rw-r--r--test/sql/test_insert.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py
index d3bc11a96..6d41a4dca 100644
--- a/test/sql/test_insert.py
+++ b/test/sql/test_insert.py
@@ -839,6 +839,39 @@ class MultirowTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL):
checkparams=checkparams,
dialect=dialect)
+ def test_named_with_column_objects(self):
+ table1 = self.tables.mytable
+
+ values = [
+ {table1.c.myid: 1, table1.c.name: 'a', table1.c.description: 'b'},
+ {table1.c.myid: 2, table1.c.name: 'c', table1.c.description: 'd'},
+ {table1.c.myid: 3, table1.c.name: 'e', table1.c.description: 'f'},
+ ]
+
+ checkparams = {
+ 'myid_m0': 1,
+ 'myid_m1': 2,
+ 'myid_m2': 3,
+ 'name_m0': 'a',
+ 'name_m1': 'c',
+ 'name_m2': 'e',
+ 'description_m0': 'b',
+ 'description_m1': 'd',
+ 'description_m2': 'f',
+ }
+
+ dialect = default.DefaultDialect()
+ dialect.supports_multivalues_insert = True
+
+ self.assert_compile(
+ table1.insert().values(values),
+ 'INSERT INTO mytable (myid, name, description) VALUES '
+ '(:myid_m0, :name_m0, :description_m0), '
+ '(:myid_m1, :name_m1, :description_m1), '
+ '(:myid_m2, :name_m2, :description_m2)',
+ checkparams=checkparams,
+ dialect=dialect)
+
def test_positional(self):
table1 = self.tables.mytable