]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Implement connection binding for AsyncSession
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 7 Jan 2021 03:56:14 +0000 (22:56 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 7 Jan 2021 20:59:59 +0000 (15:59 -0500)
commitb45aa7c4062bafae23286c3069571c2596aabc66
tree12d496c61ab71e02ca0fa1c785ee8b34d577b73a
parent7f92fdbd8ec479a61c53c11921ce0688ad4dd94b
Implement connection binding for AsyncSession

Implemented "connection-binding" for :class:`.AsyncSession`, the ability to
pass an :class:`.AsyncConnection` to create an :class:`.AsyncSession`.
Previously, this use case was not implemented and would use the associated
engine when the connection were passed.  This fixes the issue where the
"join a session to an external transaction" use case would not work
correctly for the :class:`.AsyncSession`.  Additionally, added methods
:meth:`.AsyncConnection.in_transaction`,
:meth:`.AsyncConnection.in_nested_transaction`,
:meth:`.AsyncConnection.get_transaction`.

The :class:`.AsyncEngine`, :class:`.AsyncConnection` and
:class:`.AsyncTransaction` objects may be compared using Python ``==`` or
``!=``, which will compare the two given objects based on the "sync" object
they are proxying towards. This is useful as there are cases particularly
for :class:`.AsyncTransaction` where multiple instances of
:class:`.AsyncTransaction` can be proxying towards the same sync
:class:`_engine.Transaction`, and are actually equivalent.   The
:meth:`.AsyncConnection.get_transaction` method will currently return a new
proxying :class:`.AsyncTransaction` each time as the
:class:`.AsyncTransaction` is not otherwise statefully associated with its
originating :class:`.AsyncConnection`.

Fixes: #5811
Change-Id: I5a3a6b2f088541eee7b0e0f393510e61bc9f986b
doc/build/changelog/unreleased_14/5811.rst [new file with mode: 0644]
lib/sqlalchemy/ext/asyncio/base.py
lib/sqlalchemy/ext/asyncio/engine.py
lib/sqlalchemy/ext/asyncio/session.py
lib/sqlalchemy/testing/__init__.py
lib/sqlalchemy/testing/assertions.py
test/ext/asyncio/test_engine_py3k.py
test/ext/asyncio/test_session_py3k.py