self._connections.trans.append(self.contextual_connect().begin())
def prepare(self):
- if not self._connections.trans:
+ if not hasattr(self._connections, 'trans') or \
+ not self._connections.trans:
return
self._connections.trans[-1].prepare()
def commit(self):
- if not self._connections.trans:
+ if not hasattr(self._connections, 'trans') or \
+ not self._connections.trans:
return
trans = self._connections.trans.pop(-1)
trans.commit()
def rollback(self):
- if not self._connections.trans:
+ if not hasattr(self._connections, 'trans') or \
+ not self._connections.trans:
return
trans = self._connections.trans.pop(-1)
trans.rollback()
tlengine.close()
def test_rollback_no_trans(self):
+ tlengine = create_engine(testing.db.url, strategy="threadlocal")
+
+ # shouldn't fail
+ tlengine.rollback()
+
+ tlengine.begin()
+ tlengine.rollback()
+
# shouldn't fail
tlengine.rollback()
def test_commit_no_trans(self):
+ tlengine = create_engine(testing.db.url, strategy="threadlocal")
+
+ # shouldn't fail
+ tlengine.commit()
+
+ tlengine.begin()
+ tlengine.rollback()
+
# shouldn't fail
tlengine.commit()
def test_prepare_no_trans(self):
+ tlengine = create_engine(testing.db.url, strategy="threadlocal")
+
+ # shouldn't fail
+ tlengine.prepare()
+
+ tlengine.begin()
+ tlengine.rollback()
+
# shouldn't fail
tlengine.prepare()