From: Mike Bayer Date: Wed, 4 Nov 2009 17:15:36 +0000 (+0000) Subject: - Fixed bug in two-phase transaction whereby commit() method X-Git-Tag: rel_0_6beta1~186 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a69a094db57ab1c6220930274a96457b0c353221;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Fixed bug in two-phase transaction whereby commit() method didn't set the full state which allows subsequent close() call to succeed. [ticket:1603] --- diff --git a/CHANGES b/CHANGES index 9e6d45a0af..57b79ea159 100644 --- a/CHANGES +++ b/CHANGES @@ -681,6 +681,10 @@ CHANGES appeared in the columns list. [ticket:1602] - sql + - Fixed bug in two-phase transaction whereby commit() method + didn't set the full state which allows subsequent close() + call to succeed. [ticket:1603] + - Fixed the "numeric" paramstyle, which apparently is the default paramstyle used by Informixdb. diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 33a30201fc..b65843f48d 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -1204,7 +1204,6 @@ class Transaction(object): This is used to cancel a Transaction without affecting the scope of an enclosing transaction. """ - if not self._parent.is_active: return if self._parent is self: @@ -1278,7 +1277,7 @@ class TwoPhaseTransaction(Transaction): def _do_rollback(self): self.connection._rollback_twophase_impl(self.xid, self._is_prepared) - def commit(self): + def _do_commit(self): self.connection._commit_twophase_impl(self.xid, self._is_prepared) diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index 11dd0e0102..82b767b0eb 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -226,6 +226,7 @@ class TransactionTest(TestBase): transaction = connection.begin_twophase() connection.execute(users.insert(), user_id=2, user_name='user2') transaction.commit() + transaction.close() transaction = connection.begin_twophase() connection.execute(users.insert(), user_id=3, user_name='user3') @@ -235,7 +236,8 @@ class TransactionTest(TestBase): connection.execute(users.insert(), user_id=4, user_name='user4') transaction.prepare() transaction.rollback() - + transaction.close() + eq_( connection.execute(select([users.c.user_id]).order_by(users.c.user_id)).fetchall(), [(1,),(2,)]