raise a catchable data error during results
(i.e. doesn't work on MySQL) [ticket:978]
+ - implemented two-phase API for "threadlocal" engine,
+ via engine.begin_twophase(), engine.prepare()
+ [ticket:936]
+
- orm
- any(), has(), contains(), attribute level == and != now
work properly with self-referential relations - the clause
def prepare(self):
if self.__tcount == 1:
- try:
- self.__trans._trans.prepare()
- finally:
- self.reset()
+ self.__trans._trans.prepare()
def begin_twophase(self, xid=None):
- raise NotImplementedError(
- "Two phase transactions not yet implemented for 'threadlocal' "
- "strategy")
-
- def _dont_begin_twophase(self, xid=None):
if self.__tcount == 0:
self.__transaction = self.get_connection()
self.__trans = self.__transaction._begin_twophase(xid=xid)
return self.session.get_connection(**kwargs)
+ def begin_twophase(self, **kwargs):
+ return self.session.begin_twophase(**kwargs)
+
def begin(self, **kwargs):
return self.session.begin(**kwargs)
+ def prepare(self):
+ self.session.prepare()
+
def commit(self):
self.session.commit()
c2.close()
assert c1.connection.connection is not None
+ @testing.unsupported('sqlite', 'mssql', 'firebird', 'sybase', 'access',
+ 'oracle', 'maxdb')
+ @testing.exclude('mysql', '<', (5, 0, 3))
+ def testtwophasetransaction(self):
+ tlengine.begin_twophase()
+ tlengine.execute(users.insert(), user_id=1, user_name='user1')
+ tlengine.prepare()
+ tlengine.commit()
+
+ tlengine.begin_twophase()
+ tlengine.execute(users.insert(), user_id=2, user_name='user2')
+ tlengine.commit()
+
+ tlengine.begin_twophase()
+ tlengine.execute(users.insert(), user_id=3, user_name='user3')
+ tlengine.rollback()
+
+ tlengine.begin_twophase()
+ tlengine.execute(users.insert(), user_id=4, user_name='user4')
+ tlengine.prepare()
+ tlengine.rollback()
+
+ self.assertEquals(
+ tlengine.execute(select([users.c.user_id]).order_by(users.c.user_id)).fetchall(),
+ [(1,),(2,)]
+ )
class ForUpdateTest(TestBase):
def setUpAll(self):