]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
got row switch more or less up
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 3 Apr 2010 22:24:04 +0000 (18:24 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 3 Apr 2010 22:24:04 +0000 (18:24 -0400)
lib/sqlalchemy/orm/mapper.py
lib/sqlalchemy/orm/unitofwork.py

index 22b5e5177adcddba2cbacfcb567f2b87829a184b..319b06158646aa01db0754accdc3759f3791cd87 100644 (file)
@@ -1340,8 +1340,8 @@ class Mapper(object):
         if not postupdate:
             for state, mapper, connection, has_identity, instance_key in tups:
                 # detect if we have a "pending" instance (i.e. has no instance_key attached to it),
-                # and another instance with the same identity key already exists as persistent.  convert to an
-                # UPDATE if so.
+                # and another instance with the same identity key already exists as persistent. 
+                # convert to an UPDATE if so.
                 if not has_identity and instance_key in uowtransaction.session.identity_map:
                     instance = uowtransaction.session.identity_map[instance_key]
                     existing = attributes.instance_state(instance)
@@ -1356,7 +1356,7 @@ class Mapper(object):
                         "transaction", instance_key, state_str(state), state_str(existing))
                             
                     # remove the "delete" flag from the existing element
-                    uowtransaction.set_row_switch(existing)
+                    uowtransaction.remove_state_actions(existing)
                     row_switches[state] = existing
         
         table_to_mapper = self._sorted_tables
index ceed4c28855609eed19fee1aaa73160e39757e11..a4eb00f70acf31a2c314222a4b239716d9c2cad0 100644 (file)
@@ -101,6 +101,19 @@ class UOWTransaction(object):
     def is_deleted(self, state):
         """return true if the given state is marked as deleted within this UOWTransaction."""
         return state in self.states and self.states[state][0]
+    
+    def remove_state_actions(self, state):
+        """remove pending actions for a state from the uowtransaction."""
+        
+        if state in self.states:
+            isdelete, listonly = self.states[state]
+            self.states[state] = (False, True)
+            if isdelete:
+                self.postsort_actions.pop((DeleteState, state), None)
+            else:
+                self.postsort_actions.pop((SaveUpdateState, state), None)
+                
+        
         
     def get_attribute_history(self, state, key, passive=True):
         hashkey = ("history", state, key)