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)
"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
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)