Patches item #1524615, was opened at 2006-07-18 19:38
Message generated for change (Settings changed) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1524615&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Luke Opperman (luke_opperman)
>Assigned to: Oleg Broytmann (phd)
Summary: Transaction.commit(close=True) fails to synchronize deletes
Initial Comment:
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.
Test and fix below:
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)
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2006-08-09 19:16
Message:
Logged In: YES
user_id=4799
Applied at rev. 1840. Thank you!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540674&aid=1524615&group_id=74338
|