]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- added "rollback_returned" option to Pool which will
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 May 2008 15:52:09 +0000 (15:52 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 5 May 2008 15:52:09 +0000 (15:52 +0000)
      disable the rollback() issued when connections are
      returned.  This flag is only safe to use with a database
      which does not support transactions (i.e. MySQL/MyISAM).

CHANGES
lib/sqlalchemy/pool.py

diff --git a/CHANGES b/CHANGES
index 8e39524194ccf6917e85eb105f367b65177ad986..4ac82c2edc5f03346f39ccdd0d965b01f979a7d7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -83,6 +83,11 @@ CHANGES
     - Pool listeners can now be provided as a dictionary of
       callables or a (possibly partial) duck-type of
       PoolListener, your choice.
+      
+    - added "rollback_returned" option to Pool which will 
+      disable the rollback() issued when connections are 
+      returned.  This flag is only safe to use with a database
+      which does not support transactions (i.e. MySQL/MyISAM).
 
 - mssql
     - Added "odbc_autotranslate" parameter to engine / dburi
index 71c0c82df5e43c7ef35580561e74df61aff24111..232f188e328144c19cd9df0cb236e82bdb2e3656 100644 (file)
@@ -112,7 +112,7 @@ class Pool(object):
 
     """
 
-    def __init__(self, creator, recycle=-1, echo=None, use_threadlocal=True,
+    def __init__(self, creator, recycle=-1, echo=None, use_threadlocal=True, rollback_returned=True,
                  listeners=None):
         self.logger = logging.instance_logger(self, echoflag=echo)
         # the WeakValueDictionary works more nicely than a regular dict
@@ -122,6 +122,7 @@ class Pool(object):
         self._creator = creator
         self._recycle = recycle
         self._use_threadlocal = use_threadlocal
+        self._rollback_returned = rollback_returned
         self.echo = echo
         self.listeners = []
         self._on_connect = []
@@ -288,7 +289,8 @@ def _finalize_fairy(connection, connection_record, pool, ref=None):
         return
     if connection is not None:
         try:
-            connection.rollback()
+            if pool._rollback_returned:
+                connection.rollback()
             # Immediately close detached instances
             if connection_record is None:
                 connection.close()