diff options
| -rw-r--r-- | doc/build/changelog/unreleased_14/6220.rst | 6 | ||||
| -rw-r--r-- | lib/sqlalchemy/ext/asyncio/session.py | 2 | ||||
| -rw-r--r-- | test/ext/asyncio/test_session_py3k.py | 9 |
3 files changed, 16 insertions, 1 deletions
diff --git a/doc/build/changelog/unreleased_14/6220.rst b/doc/build/changelog/unreleased_14/6220.rst new file mode 100644 index 000000000..8a276243a --- /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 c8377aa65..d8a5673eb 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 032176ea6..feb557471 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 |
