From: Mike Bayer Date: Mon, 5 May 2008 15:52:09 +0000 (+0000) Subject: - added "rollback_returned" option to Pool which will X-Git-Tag: rel_0_5beta1~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=635e61bdebfc8fefb93cad2550b1342c43b63186;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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). --- diff --git a/CHANGES b/CHANGES index 8e39524194..4ac82c2edc 100644 --- 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 diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index 71c0c82df5..232f188e32 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -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()