summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-10-21 13:58:22 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-10-21 14:03:12 -0400
commite3dc20ff27fa75e571fb2631e64737ea8f25f7c5 (patch)
tree7bc037f85ad4a3ac0399bef46fb05bdefd1f1973 /lib/sqlalchemy
parent04d45f8adeafe5bb8981e7cfd94b11d36248d860 (diff)
downloadsqlalchemy-e3dc20ff27fa75e571fb2631e64737ea8f25f7c5.tar.gz
Don't populate expired attrs w/ evaluator
Fixed bug in :meth:`_orm.Query.update` where objects in the :class:`_orm.Session` that were already expired would be unnecessarily SELECTed individually when they were refreshed by the "evaluate" synchronize strategy. For 1.4 there was also a similar issue with fetch that would actually get the wrong data back, as the new value would be loaded, then applied with the evaluator. Fixes: #5664 Change-Id: I6e6aff88462654fcefa9fce2b45f5446c418deee
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/persistence.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py
index 4a0b2d07d..1794cc2ce 100644
--- a/lib/sqlalchemy/orm/persistence.py
+++ b/lib/sqlalchemy/orm/persistence.py
@@ -2209,6 +2209,8 @@ class BulkORMUpdate(UpdateDMLState, BulkUDCompileState):
# only evaluate unmodified attributes
to_evaluate = state.unmodified.intersection(evaluated_keys)
for key in to_evaluate:
+ if key not in dict_:
+ continue
dict_[key] = update_options._value_evaluators[key](obj)
state.manager.dispatch.refresh(state, None, to_evaluate)
@@ -2264,7 +2266,8 @@ class BulkORMUpdate(UpdateDMLState, BulkUDCompileState):
to_evaluate = state.unmodified.intersection(evaluated_keys)
for key in to_evaluate:
- dict_[key] = update_options._value_evaluators[key](obj)
+ if key in dict_:
+ dict_[key] = update_options._value_evaluators[key](obj)
state.manager.dispatch.refresh(state, None, to_evaluate)
state._commit(dict_, list(to_evaluate))