summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-12-14 17:53:56 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-12-14 17:53:56 -0500
commitd0fc7269888247517ffa16d9472f961ebec892a7 (patch)
tree3d5aaf818261879192ba6492b6c6639b16cb6954 /lib/sqlalchemy
parent26ed90ab22dde7bdafe933cb1d16acfe70c1ab78 (diff)
downloadsqlalchemy-d0fc7269888247517ffa16d9472f961ebec892a7.tar.gz
- since we are mutating the statement in a loop, start with
the same cached starting statement each time. no issue has been observed with the former but it could perhaps have issues w/ versioning or eager_defaults
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/persistence.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py
index 77c513aef..e6a2c0634 100644
--- a/lib/sqlalchemy/orm/persistence.py
+++ b/lib/sqlalchemy/orm/persistence.py
@@ -628,7 +628,7 @@ def _emit_update_statements(base_mapper, uowtransaction,
stmt = table.update(clause)
return stmt
- statement = base_mapper._memo(('update', table), update_stmt)
+ cached_stmt = base_mapper._memo(('update', table), update_stmt)
for (connection, paramkeys, hasvalue, has_all_defaults), \
records in groupby(
@@ -643,6 +643,8 @@ def _emit_update_statements(base_mapper, uowtransaction,
rows = 0
records = list(records)
+ statement = cached_stmt
+
# TODO: would be super-nice to not have to determine this boolean
# inside the loop here, in the 99.9999% of the time there's only
# one connection in use
@@ -651,7 +653,8 @@ def _emit_update_statements(base_mapper, uowtransaction,
connection.dialect.supports_sane_multi_rowcount
allow_multirow = has_all_defaults and not needs_version_id
- if bookkeeping and mapper.base_mapper.eager_defaults:
+ if bookkeeping and not has_all_defaults and \
+ mapper.base_mapper.eager_defaults:
statement = statement.return_defaults()
elif mapper.version_id_col is not None:
statement = statement.return_defaults(mapper.version_id_col)
@@ -739,7 +742,7 @@ def _emit_insert_statements(base_mapper, uowtransaction,
"""Emit INSERT statements corresponding to value lists collected
by _collect_insert_commands()."""
- statement = base_mapper._memo(('insert', table), table.insert)
+ cached_stmt = base_mapper._memo(('insert', table), table.insert)
for (connection, pkeys, hasvalue, has_all_pks, has_all_defaults), \
records in groupby(
@@ -751,6 +754,8 @@ def _emit_insert_statements(base_mapper, uowtransaction,
rec[6],
rec[7])):
+ statement = cached_stmt
+
if not bookkeeping or \
(
has_all_defaults