]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- fixed bug where Connection wouldnt lose its Transaction
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Sep 2006 20:06:42 +0000 (20:06 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 12 Sep 2006 20:06:42 +0000 (20:06 +0000)
after commit/rollback

CHANGES
lib/sqlalchemy/engine/base.py
test/engine/transaction.py

diff --git a/CHANGES b/CHANGES
index b0d75ea72fd1a09bfcf0fbf1ea508430c26a133f..67a359b319fe974fc6bd8d5a55630aa17ab32b8d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,8 @@ arguments into a for_update argument on the select side.
 - implemented "version check" logic in Query/Mapper, used
 when version_id_col is in effect and query.with_lockmode()
 is used to get() an instance thats already loaded
+- fixed bug where Connection wouldnt lose its Transaction
+after commit/rollback
 
 0.2.8
 - cleanup on connection methods + documentation.  custom DBAPI
index ce6cc7d82ef365011d76d42dd2a119492992f383..fad84eef864dd5cd97cc0bc5b540374e225642a2 100644 (file)
@@ -211,10 +211,12 @@ class Connection(Connectable):
         if self.__engine.echo:
             self.__engine.log("ROLLBACK")
         self.__engine.dialect.do_rollback(self.connection)
+        self.__transaction = None
     def _commit_impl(self):
         if self.__engine.echo:
             self.__engine.log("COMMIT")
         self.__engine.dialect.do_commit(self.connection)
+        self.__transaction = None
     def _autocommit(self, statement):
         """when no Transaction is present, this is called after executions to provide "autocommit" behavior."""
         # TODO: have the dialect determine if autocommit can be set on the connection directly without this 
index 6711af8b8aadf3347c8909f02a2ead5d9286d285..c2d278b6a2cd1af19cd0085d5c3b8670bfe05eb8 100644 (file)
@@ -21,6 +21,22 @@ class TransactionTest(testbase.PersistTest):
     def tearDownAll(self):
         users.drop(testbase.db)
     
+    def testcommits(self):
+        connection = testbase.db.connect()
+        transaction = connection.begin()
+        connection.execute(users.insert(), user_id=1, user_name='user1')
+        transaction.commit()
+
+        transaction = connection.begin()
+        connection.execute(users.insert(), user_id=2, user_name='user2')
+        connection.execute(users.insert(), user_id=3, user_name='user3')
+        transaction.commit()
+
+        transaction = connection.begin()
+        result = connection.execute("select * from query_users")
+        assert len(result.fetchall()) == 3
+        transaction.commit()
+        
     @testbase.unsupported('mysql')
     def testrollback(self):
         """test a basic rollback"""
@@ -157,6 +173,22 @@ class TLTransactionTest(testbase.PersistTest):
         finally:
             external_connection.close()
 
+    def testcommits(self):
+        connection = tlengine.contextual_connect()
+        transaction = connection.begin()
+        connection.execute(users.insert(), user_id=1, user_name='user1')
+        transaction.commit()
+
+        transaction = connection.begin()
+        connection.execute(users.insert(), user_id=2, user_name='user2')
+        connection.execute(users.insert(), user_id=3, user_name='user3')
+        transaction.commit()
+
+        transaction = connection.begin()
+        result = connection.execute("select * from query_users")
+        assert len(result.fetchall()) == 3
+        transaction.commit()
+
     @testbase.unsupported('mysql')
     def testrollback_off_conn(self):
         # test that a TLTransaction opened off a TLConnection allows that