summaryrefslogtreecommitdiff
path: root/odoo/sql_db.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-02-05 11:41:23 +0100
committerChristophe Simonis <chs@odoo.com>2019-02-05 11:41:23 +0100
commit53ba83579beeb330312d9e4066ae05145dd40caa (patch)
tree7b4d3c99140935a73296a61d3fa4eb65d098e38d /odoo/sql_db.py
parentaaa2035bcf700761129b3e64ff6e845a1116e1e6 (diff)
parent8cb2965e2329ca16a4885a5d54df3bf3c5c23eb8 (diff)
[MERGE] forward port branch 10.0 up to 8cb2965e232
Diffstat (limited to 'odoo/sql_db.py')
-rw-r--r--odoo/sql_db.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/odoo/sql_db.py b/odoo/sql_db.py
index 4cc6163a96f..74575c4e810 100644
--- a/odoo/sql_db.py
+++ b/odoo/sql_db.py
@@ -432,16 +432,18 @@ class TestCursor(Cursor):
"""
def __init__(self, *args, **kwargs):
super(TestCursor, self).__init__(*args, **kwargs)
- # in order to simulate commit and rollback, the cursor maintains a
- # savepoint at its last commit
- self.execute("SAVEPOINT test_cursor")
# we use a lock to serialize concurrent requests
self._lock = threading.RLock()
def acquire(self):
self._lock.acquire()
+ # the cursor maintains a savepoint at its last commit point
+ self.execute("SAVEPOINT test_cursor")
def release(self):
+ # the cursor should be right after the savepoint; release it to make
+ # former savepoints directly accessible
+ self.execute("RELEASE SAVEPOINT test_cursor")
self._lock.release()
def force_close(self):
@@ -456,12 +458,13 @@ class TestCursor(Cursor):
_logger.debug("TestCursor.autocommit(%r) does nothing", on)
def commit(self):
+ # move the savepoint to the current position
self.execute("RELEASE SAVEPOINT test_cursor")
self.execute("SAVEPOINT test_cursor")
def rollback(self):
+ # this does not release the savepoint; release() will do it
self.execute("ROLLBACK TO SAVEPOINT test_cursor")
- self.execute("SAVEPOINT test_cursor")
class LazyCursor(object):
""" A proxy object to a cursor. The cursor itself is allocated only if it is