summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
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 /lib/sqlalchemy
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 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/sql/crud.py39
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/sqlalchemy/sql/crud.py b/lib/sqlalchemy/sql/crud.py
index 8421b1e66..8f058d756 100644
--- a/lib/sqlalchemy/sql/crud.py
+++ b/lib/sqlalchemy/sql/crud.py
@@ -600,23 +600,28 @@ def _extend_values_for_multiparams(compiler, stmt, values, kw):
values_0 = values
values = [values]
- values.extend(
- [
- (
- c,
- (_create_bind_param(
- compiler, c, row[c.key],
- 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))
- if c.key in row else
- _process_multiparam_default_bind(compiler, stmt, c, i, kw)
- )
- for (c, param) in values_0
- ]
- for i, row in enumerate(stmt.parameters[1:])
- )
+ for i, row in enumerate(stmt.parameters[1:]):
+ extension = []
+ for (col, param) in values_0:
+ if col in row or col.key in row:
+ key = col if col in row else col.key
+
+ if elements._is_literal(row[key]):
+ new_param = _create_bind_param(
+ compiler, col, row[key],
+ name="%s_m%d" % (col.key, i + 1), **kw
+ )
+ else:
+ new_param = compiler.process(row[key].self_group(), **kw)
+ else:
+ new_param = _process_multiparam_default_bind(
+ compiler, stmt, col, i, kw
+ )
+
+ extension.append((col, new_param))
+
+ values.append(extension)
+
return values