Commit 7510464b authored by Jim Fulton's avatar Jim Fulton

Fixed a bug in commits with savepoints and changes since savepoints.

Once we start using savepoints, we need to make sure that all data are
committed through the savepoints. Otherwise, things can get committed
in the wrong order, leading to conflicts.
parent 752bf524
......@@ -63,7 +63,6 @@ class Connection(ExportImport, object):
_storage = _normal_storage = _savepoint_storage = None
_tmp = None
_code_timestamp = 0
##########################################################################
......@@ -437,8 +436,16 @@ class Connection(ExportImport, object):
"""Commit changes to an object"""
if self._savepoint_storage is not None:
# We first checkpoint the current changes to the savepoint
self.savepoint()
# then commit all of the savepoint changes at once
self._commit_savepoint(transaction)
# No need to call _commit since savepoint did.
else:
self._commit(transaction)
def _commit(self, transaction):
......
......@@ -33,6 +33,21 @@ def testAddingThenModifyThenAbort():
>>> transaction.abort()
"""
def testModifyThenSavePointThenModifySomeMoreThenCommit():
"""
>>> import ZODB.tests.util
>>> db = ZODB.tests.util.DB()
>>> connection = db.open()
>>> root = connection.root()
>>> sp = transaction.savepoint()
>>> root['a'] = 1
>>> sp = transaction.savepoint()
>>> root['a'] = 2
>>> transaction.commit()
"""
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('testConnectionSavepoint.txt'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment