http://sourceforge.net/tracker/index.php?func=detail&aid=1524615&group_id=74338&atid=540674

With close=True, Transaction.commit() calls
_makeObsolete before synchronizing the main connection
cache - this resets Transaction._deletedCache, so
objects deleted in the transaction are never expired.

Index: dbconnection.py
===================================================================
--- dbconnection.py     (revision 1827)
+++ dbconnection.py     (working copy)
@@ -837,8 +837,6 @@
         if self._dbConnection.debug:
             self._dbConnection.printDebug(self._connection, '', 'COMMIT')
         self._connection.commit()
-        if close:
-            self._makeObsolete()
         subCaches = [(sub[0], sub[1].allIDs()) for sub in self.cache.allSubCachesByClassNames().items()]
         subCaches.extend([(x[0], x[1]) for x in self._deletedCache.items()])
         for cls, ids in subCaches:
@@ -846,6 +844,8 @@
                 inst = self._dbConnection.cache.tryGetByName(id, cls)
                 if inst is not None:
                     inst.expire()
+        if close:
+            self._makeObsolete()

     def rollback(self):
         if self._obsolete:
Index: tests/test_transactions.py
===================================================================
--- tests/test_transactions.py  (revision 1827)
+++ tests/test_transactions.py  (working copy)
@@ -52,7 +52,7 @@
     finally:
         TestSOTrans._connection.autoCommit = True

-def test_transaction_delete():
+def test_transaction_delete(close=False):
     if not supports('transactions'):
         return
     setupClass(TestSOTrans)
@@ -63,5 +63,14 @@
         bIn.destroySelf()
         bOut = TestSOTrans.select(TestSOTrans.q.name=='bob')
         assert bOut.count() == 1
+        bOutInst = bOut[0]
+        bOutID = bOutInst.id
+        trans.commit(close=close)
+        assert bOut.count() == 0
+        raises(SQLObjectNotFound, "TestSOTrans.get(bOutID)")
+        raises(SQLObjectNotFound, "bOutInst.name")
     finally:
         TestSOTrans._connection.autoCommit = True
+
+def test_transaction_delete_with_close():
+    test_transaction_delete(close=True)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to