From a30ffd71b9f5dc6ff2c56a57f45d86f1313df354 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 8 Apr 2010 14:15:11 -0400 Subject: [PATCH] we can load this sum ahead of time, and if there is none, we dont need a per-state/proc for this at all. this greatly reduces unnecessary crap in the UOW for complex models. --- lib/sqlalchemy/orm/dependency.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index d02776dcee..98840800f3 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -162,6 +162,16 @@ class DependencyProcessor(object): # now create actions /dependencies for each state. for state in states: + # 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() + if not sum_: + continue + # I'd like to emit the before_delete/after_save actions # here and have the unit of work not get confused by that # when it alters the list of dependencies... @@ -181,15 +191,7 @@ class DependencyProcessor(object): parent_base_mapper) if child_in_cycles: - # locate each child state associated with the parent action, - # create dependencies for each. child_actions = [] - sum_ = uow.get_attribute_history( - state, - self.key, - passive=True).sum() - if not sum_: - continue for child_state in sum_: if child_state is None: continue -- 2.47.3