From: Mike Bayer Date: Thu, 8 Apr 2010 18:15:11 +0000 (-0400) Subject: we can load this sum ahead of time, and if there is none, we dont need a per-state... X-Git-Tag: rel_0_6_0~37 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a30ffd71b9f5dc6ff2c56a57f45d86f1313df354;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git 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. --- 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