summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-09-08 13:00:26 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-09-08 13:00:26 -0400
commit68a6701c6d72d6c6ef1ea2b7d615273659e8b735 (patch)
treeaafd38ed52a00323f74af21b329d84571efcc1d1 /lib/sqlalchemy/orm
parent176ac6ab0915f99d378c7d9be67e9c0a73ab1800 (diff)
downloadsqlalchemy-68a6701c6d72d6c6ef1ea2b7d615273659e8b735.tar.gz
- Fixed bug in :meth:`.Session.bulk_save_objects` where a mapped
column that had some kind of "fetch on update" value and was not locally present in the given object would cause an AttributeError within the operation. fixes #3525
Diffstat (limited to 'lib/sqlalchemy/orm')
-rw-r--r--lib/sqlalchemy/orm/persistence.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py
index c785a4dee..64872288e 100644
--- a/lib/sqlalchemy/orm/persistence.py
+++ b/lib/sqlalchemy/orm/persistence.py
@@ -672,6 +672,8 @@ def _emit_update_statements(base_mapper, uowtransaction,
connection, value_params in records:
c = cached_connections[connection].\
execute(statement, params)
+
+ # TODO: why with bookkeeping=False?
_postfetch(
mapper,
uowtransaction,
@@ -694,6 +696,8 @@ def _emit_update_statements(base_mapper, uowtransaction,
execute(statement, multiparams)
rows += c.rowcount
+
+ # TODO: why with bookkeeping=False?
for state, state_dict, params, mapper, \
connection, value_params in records:
_postfetch(
@@ -964,6 +968,8 @@ def _postfetch(mapper, uowtransaction, table,
after an INSERT or UPDATE statement has proceeded for that
state."""
+ # TODO: bulk is never non-False, need to clean this up
+
prefetch_cols = result.context.compiled.prefetch
postfetch_cols = result.context.compiled.postfetch
returning_cols = result.context.compiled.returning
@@ -996,7 +1002,7 @@ def _postfetch(mapper, uowtransaction, table,
mapper.class_manager.dispatch.refresh_flush(
state, uowtransaction, load_evt_attrs)
- if postfetch_cols:
+ if postfetch_cols and state:
state._expire_attributes(state.dict,
[mapper._columntoproperty[c].key
for c in postfetch_cols if c in