From: Federico Caselli Date: Sat, 10 Apr 2021 13:24:21 +0000 (+0200) Subject: Fix typo that prevented setting the ``bind`` X-Git-Tag: rel_1_4_8~11^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3d41fad27de91800b89a199e67766066fd744103;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Fix typo that prevented setting the ``bind`` attribute of an :class:`_asyncio.AsyncSession` to the correct value. Fixes: #6220 Change-Id: I91021351b8076e4aa4139af4b2cf359b3c0404af --- diff --git a/doc/build/changelog/unreleased_14/6220.rst b/doc/build/changelog/unreleased_14/6220.rst new file mode 100644 index 0000000000..8a276243a1 --- /dev/null +++ b/doc/build/changelog/unreleased_14/6220.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: bug, asyncio + :tickets: 6220 + + Fix typo that prevented setting the ``bind`` attribute of an + :class:`_asyncio.AsyncSession` to the correct value. diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index c8377aa65f..d8a5673eb9 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -80,7 +80,7 @@ class AsyncSession: ): kw["future"] = True if bind: - self.bind = engine + self.bind = bind bind = engine._get_sync_engine_or_connection(bind) if binds: diff --git a/test/ext/asyncio/test_session_py3k.py b/test/ext/asyncio/test_session_py3k.py index 032176ea6d..feb5574711 100644 --- a/test/ext/asyncio/test_session_py3k.py +++ b/test/ext/asyncio/test_session_py3k.py @@ -2,6 +2,7 @@ from sqlalchemy import event from sqlalchemy import exc from sqlalchemy import func from sqlalchemy import select +from sqlalchemy import Table from sqlalchemy import testing from sqlalchemy import update from sqlalchemy.ext.asyncio import AsyncSession @@ -46,6 +47,14 @@ class AsyncSessionTest(AsyncFixture): eq_(async_session.sync_session.info, {"foo": "bar"}) + def test_init(self, async_engine): + ss = AsyncSession(bind=async_engine) + is_(ss.bind, async_engine) + + binds = {Table: async_engine} + ss = AsyncSession(binds=binds) + is_(ss.binds, binds) + class AsyncSessionQueryTest(AsyncFixture): @async_test