From: Mike Bayer Date: Tue, 21 Apr 2015 14:04:02 +0000 (-0400) Subject: - Added the string value ``"none"`` to those accepted by the X-Git-Tag: rel_1_0_1~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c2e3002503242331fc8f2b314e0d4f3c65de9d73;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Added the string value ``"none"`` to those accepted by the :paramref:`.Pool.reset_on_return` parameter as a synonym for ``None``, so that string values can be used for all settings, allowing .ini file utilities like :func:`.engine_from_config` to be usable without issue. fixes #3375 --- diff --git a/doc/build/changelog/changelog_09.rst b/doc/build/changelog/changelog_09.rst index 7960da626e..2f2f592635 100644 --- a/doc/build/changelog/changelog_09.rst +++ b/doc/build/changelog/changelog_09.rst @@ -14,6 +14,17 @@ .. changelog:: :version: 0.9.10 + .. change:: + :tags: bug, engine + :tickets: 3375 + :versions: 1.0.1 + + Added the string value ``"none"`` to those accepted by the + :paramref:`.Pool.reset_on_return` parameter as a synonym for ``None``, + so that string values can be used for all settings, allowing + utilities like :func:`.engine_from_config` to be usable without + issue. + .. change:: :tags: bug, sql :tickets: 3362 diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index ccb4f1e6a4..fc899ba304 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -186,6 +186,10 @@ class Pool(log.Identified): database that supports transactions, as it will lead to deadlocks and stale state. + * ``"none"`` - same as ``None`` + + .. versionadded:: 0.9.10 + * ``False`` - same as None, this is here for backwards compatibility. @@ -220,7 +224,7 @@ class Pool(log.Identified): self._use_threadlocal = use_threadlocal if reset_on_return in ('rollback', True, reset_rollback): self._reset_on_return = reset_rollback - elif reset_on_return in (None, False, reset_none): + elif reset_on_return in ('none', None, False, reset_none): self._reset_on_return = reset_none elif reset_on_return in ('commit', reset_commit): self._reset_on_return = reset_commit diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index e53a99e153..9f1b5cebad 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -138,6 +138,21 @@ class CreateEngineTest(fixtures.TestBase): 'z=somevalue') assert e.echo is True + def test_pool_reset_on_return_from_config(self): + dbapi = mock_dbapi + + for value, expected in [ + ("rollback", pool.reset_rollback), + ("commit", pool.reset_commit), + ("none", pool.reset_none) + ]: + config = { + 'sqlalchemy.url': 'postgresql://scott:tiger@somehost/test', + 'sqlalchemy.pool_reset_on_return': value} + + e = engine_from_config(config, module=dbapi, _initialize=False) + eq_(e.pool._reset_on_return, expected) + def test_engine_from_config_custom(self): from sqlalchemy import util from sqlalchemy.dialects import registry