[SQL-CVS] r1840 - in SQLObject/trunk/sqlobject: . tests
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: <sub...@co...> - 2006-08-02 14:40:49
|
Author: phd
Date: 2006-08-02 08:40:47 -0600 (Wed, 02 Aug 2006)
New Revision: 1840
Modified:
SQLObject/trunk/sqlobject/dbconnection.py
SQLObject/trunk/sqlobject/tests/test_transactions.py
Log:
A patch by Luke Opperman <lu...@me...> to fix problems with
transaction.commit(close=True).
Modified: SQLObject/trunk/sqlobject/dbconnection.py
===================================================================
--- SQLObject/trunk/sqlobject/dbconnection.py 2006-08-02 14:31:45 UTC (rev 1839)
+++ SQLObject/trunk/sqlobject/dbconnection.py 2006-08-02 14:40:47 UTC (rev 1840)
@@ -839,8 +839,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:
@@ -848,6 +846,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:
Modified: SQLObject/trunk/sqlobject/tests/test_transactions.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_transactions.py 2006-08-02 14:31:45 UTC (rev 1839)
+++ SQLObject/trunk/sqlobject/tests/test_transactions.py 2006-08-02 14:40:47 UTC (rev 1840)
@@ -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)
|