summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-04-03 18:24:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-04-03 18:24:04 -0400
commit85156a0fbe43f8691e19c077c92b0d433f9e654b (patch)
treea7c01a7e53918d03ef0e0e5b7b7f21bef8a10118 /lib
parentad8ad86470a61acecb361f673dbb74b36dedd3a7 (diff)
downloadsqlalchemy-85156a0fbe43f8691e19c077c92b0d433f9e654b.tar.gz
got row switch more or less up
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/mapper.py6
-rw-r--r--lib/sqlalchemy/orm/unitofwork.py13
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py
index 22b5e5177..319b06158 100644
--- a/lib/sqlalchemy/orm/mapper.py
+++ b/lib/sqlalchemy/orm/mapper.py
@@ -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
diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py
index ceed4c288..a4eb00f70 100644
--- a/lib/sqlalchemy/orm/unitofwork.py
+++ b/lib/sqlalchemy/orm/unitofwork.py
@@ -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)