Commits

Mike Bayer  committed e1ce67d

- Fixed bug where transaction-level "deleted"
collection wouldn't be cleared of expunged
states, raising an error if they later
became transient [ticket:2182].

  • Participants
  • Parent commits f746fa2
  • Branches rel_0_6

Comments (0)

Files changed (3)

     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

File lib/sqlalchemy/orm/session.py

             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)

File test/orm/test_session.py

         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)