]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed bug where transaction-level "deleted"
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Jun 2011 16:24:02 +0000 (12:24 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 5 Jun 2011 16:24:02 +0000 (12:24 -0400)
collection wouldn't be cleared of expunged
states, raising an error if they later
became transient [ticket:2182].

CHANGES
lib/sqlalchemy/orm/session.py
test/orm/test_session.py

diff --git a/CHANGES b/CHANGES
index da822abd925c93e0b6a912631e0779c1f79aae5e..5fb4c8a2188c30015356984d7dbcd8155cb1259e 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -56,6 +56,11 @@ CHANGES
     the Column isn't set up to detect
     auto-increment correctly; [ticket:2170].
 
+  - Fixed bug where transaction-level "deleted"
+    collection wouldn't be cleared of expunged
+    states, raising an error if they later
+    became transient [ticket:2182]. 
+
 - sql
   - Fixed bug whereby if FetchedValue was passed
     to column server_onupdate, it would not
index 61ceeeeb09c7e3580915b30a7c93eeb521558257..54cdeae3ba4e1916e2f374034bfe69020bdf7c2b 100644 (file)
@@ -1032,6 +1032,8 @@ class Session(object):
             self.identity_map.discard(state)
             self._deleted.pop(state, None)
             state.detach()
+        elif self.transaction:
+            self.transaction._deleted.pop(state, None)
 
     def _register_newly_persistent(self, state):
         mapper = _state_mapper(state)
index 5bf03bfdbcb9e0b31661b212ebfa96cdc155c4c0..8ce65d28c9d28a8446e683bec88faea43339ceea 100644 (file)
@@ -299,6 +299,20 @@ class SessionTest(_fixtures.FixtureTest):
         sess.flush()
         assert u1 in sess
 
+    @testing.resolve_artifact_names
+    def test_make_transient_plus_rollback(self):
+        # test for [ticket:2182]
+        mapper(User, users)
+        sess = Session()
+        u1 = User(name='test')
+        sess.add(u1)
+        sess.commit()
+
+        sess.delete(u1)
+        sess.flush()
+        make_transient(u1)
+        sess.rollback()
+
     @testing.resolve_artifact_names
     def test_deleted_flag(self):
         mapper(User, users)