]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
we can load this sum ahead of time, and if there is none, we dont need a per-state...
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 8 Apr 2010 18:15:11 +0000 (14:15 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 8 Apr 2010 18:15:11 +0000 (14:15 -0400)
this greatly reduces unnecessary crap in the UOW for complex models.

lib/sqlalchemy/orm/dependency.py

index d02776dcee6ebbac91ec7e1e7ab66b0c879be467..98840800f3b8a9fb712b348b755bf37e6a1a4a46 100644 (file)
@@ -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