summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/unitofwork.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-08-19 12:35:39 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-08-19 12:35:39 -0400
commit3087b8ddef6e903aff95e14742888cf2804a9206 (patch)
tree37128086224656393b4f888b673b391df3532824 /lib/sqlalchemy/orm/unitofwork.py
parentb47c185fc4b09f0ee8f8445fb1b7ea41beafa0d7 (diff)
downloadsqlalchemy-3087b8ddef6e903aff95e14742888cf2804a9206.tar.gz
- [bug] Lazy loads emitted within flush events
such as before_flush(), before_update(), etc. will now function as they would within non-event code, regarding consideration of the PK/FK values used in the lazy-emitted query. Previously, special flags would be established that would cause lazy loads to load related items based on the "previous" value of the parent PK/FK values specifically when called upon within a flush; the signal to load in this way is now localized to where the unit of work actually needs to load that way. Note that the UOW does sometimes load these collections before the before_update() event is called, so the usage of "passive_updates" or not can affect whether or not a collection will represent the "old" or "new" data, when accessed within a flush event, based on when the lazy load was emitted. The change is backwards incompatible in the exceedingly small chance that user event code depended on the old behavior. [ticket:2350]
Diffstat (limited to 'lib/sqlalchemy/orm/unitofwork.py')
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index 84c9f647c..5fb7a55e5 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -178,7 +178,8 @@ class UOWTransaction(object):
and passive & attributes.SQL_OK:
impl = state.manager[key].impl
history = impl.get_history(state, state.dict,
- attributes.PASSIVE_OFF)
+ attributes.PASSIVE_OFF |
+ attributes.LOAD_AGAINST_COMMITTED)
if history and impl.uses_objects:
state_history = history.as_state()
else:
@@ -188,12 +189,14 @@ class UOWTransaction(object):
impl = state.manager[key].impl
# TODO: store the history as (state, object) tuples
# so we don't have to keep converting here
- history = impl.get_history(state, state.dict, passive)
+ history = impl.get_history(state, state.dict, passive |
+ attributes.LOAD_AGAINST_COMMITTED)
if history and impl.uses_objects:
state_history = history.as_state()
else:
state_history = history
- self.attributes[hashkey] = (history, state_history, passive)
+ self.attributes[hashkey] = (history, state_history,
+ passive)
return state_history