summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2009-09-01 22:55:59 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2009-09-01 22:55:59 +0000
commit0eab503a87475df65e0269a4a4855fb9d1bf5e9f (patch)
tree55735074aeaeefc53e998596afb5b00cfb074cde /lib
parent31f26e561cc1aeb3475e6e662839b07a60412c36 (diff)
downloadsqlalchemy-0eab503a87475df65e0269a4a4855fb9d1bf5e9f.tar.gz
- Fixed bug which prevented two entities from mutually
replacing each other's primary key values within a single flush() for some orderings of operations. [ticket:1519]
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/orm/session.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index fdf679a42..002ccd509 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1017,8 +1017,10 @@ class Session(object):
if state.key is None:
state.key = instance_key
elif state.key != instance_key:
- # primary key switch
- self.identity_map.remove(state)
+ # primary key switch.
+ # use discard() in case another state has already replaced this
+ # one in the identity map (see test/orm/test_naturalpks.py ReversePKsTest)
+ self.identity_map.discard(state)
state.key = instance_key
self.identity_map.replace(state)