]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- use get_all_pending in per_state_flush_actions(), but we'd like to
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Dec 2010 18:59:24 +0000 (13:59 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 17 Dec 2010 18:59:24 +0000 (13:59 -0500)
streamline get_history() in any case

lib/sqlalchemy/orm/attributes.py
lib/sqlalchemy/orm/dependency.py
lib/sqlalchemy/orm/unitofwork.py

index e9f3763b19c287ffd1770301afde176c638a8450..e7ab4c3a11120883dc095cf7f8716c19cc50e32b 100644 (file)
@@ -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.
     
     """
     
index ab8045f6919ec1fba1d7632cf161ead0acfd0e7a..39ea1db35c3c8a4d9ac7fd914718818f4c631e26 100644 (file)
@@ -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:
index ab62e5324ca285fb803d4512baa04c22f9cf687b..1e1eda4a3cfcf9e04b751885e43a27a76b035c43 100644 (file)
@@ -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()