]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix typo that prevented setting the ``bind``
authorFederico Caselli <cfederico87@gmail.com>
Sat, 10 Apr 2021 13:24:21 +0000 (15:24 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Sat, 10 Apr 2021 13:24:21 +0000 (15:24 +0200)
attribute of an :class:`_asyncio.AsyncSession` to the correct value.

Fixes: #6220
Change-Id: I91021351b8076e4aa4139af4b2cf359b3c0404af

doc/build/changelog/unreleased_14/6220.rst [new file with mode: 0644]
lib/sqlalchemy/ext/asyncio/session.py
test/ext/asyncio/test_session_py3k.py

diff --git a/doc/build/changelog/unreleased_14/6220.rst b/doc/build/changelog/unreleased_14/6220.rst
new file mode 100644 (file)
index 0000000..8a27624
--- /dev/null
@@ -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.
index c8377aa65f30b8c1bc02a1064b3daa2df161abd5..d8a5673eb97894c92224cc4c0c6393e789081a17 100644 (file)
@@ -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:
index 032176ea6d60eca764582ac8537edab8d6060ac5..feb5574711fd1902088c4a366c3a280378b827a4 100644 (file)
@@ -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