From: Mike Bayer Date: Fri, 17 Dec 2010 18:59:24 +0000 (-0500) Subject: - use get_all_pending in per_state_flush_actions(), but we'd like to X-Git-Tag: rel_0_7b1~157^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ba964522e15da9062f5ed11e8bf55a0b5fb54693;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - use get_all_pending in per_state_flush_actions(), but we'd like to streamline get_history() in any case --- diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index e9f3763b19..e7ab4c3a11 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -663,6 +663,7 @@ class CollectionAttributeImpl(AttributeImpl): if original is NO_VALUE: return list(current) else: + # TODO: use the dict() of state, obj here current_set = util.IdentitySet(current) original_set = util.IdentitySet(original) @@ -1081,6 +1082,10 @@ def get_all_pending(state, dict_, key): state, key, passive=PASSIVE_NO_INITIALIZE).sum() + + TODO: we'd like to more closely merge the "history" tuple + generation with "get_all_pending()", making the presence + of the "History" object optional. """ diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index ab8045f691..39ea1db35c 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -152,10 +152,8 @@ class DependencyProcessor(object): # detect if there's anything changed or loaded # by a preprocessor on this state/attribute. if not, # we should be able to skip it entirely. - sum_ = uow.get_attribute_history( - state, - self.key, - passive=True).sum() + sum_ = attributes.get_all_pending(state, state.dict, self.key) + if not sum_: continue @@ -177,9 +175,10 @@ class DependencyProcessor(object): if child_in_cycles: child_actions = [] - for child_state in sum_: - if child_state is None: + for child in sum_: + if child is None: continue + child_state = attributes.instance_state(child) if child_state not in uow.states: child_action = (None, None) else: diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index ab62e5324c..1e1eda4a3c 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -166,6 +166,8 @@ class UOWTransaction(object): self.attributes[hashkey] = (history, state_history, passive) else: 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=passive) if history and impl.uses_objects: state_history = history.as_state()