Skip to content

Commit 9645d4f

Browse files
Fix regression when using a connection type when creating a pool.
1 parent 3aad0aa commit 9645d4f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/oracledb/pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def _set_connection_type(self, conn_class):
411411
conn_class = connection_module.Connection
412412
elif not issubclass(
413413
conn_class, connection_module.Connection
414-
) or issubclass(connection_module.AsyncConnection):
414+
) or issubclass(conn_class, connection_module.AsyncConnection):
415415
errors._raise_err(errors.ERR_INVALID_CONN_CLASS)
416416
self._connection_type = conn_class
417417
self._connection_method = oracledb.connect

tests/test_2400_pool.py

+10
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,16 @@ def test_2434_invalid_pool_class(self):
866866
pool_class=int,
867867
)
868868

869+
def test_2435_pool_with_connectiontype(self):
870+
"2435 - test creating a pool with a subclassed connection type"
871+
872+
class MyConnection(oracledb.Connection):
873+
pass
874+
875+
pool = test_env.get_pool(connectiontype=MyConnection)
876+
with pool.acquire() as conn:
877+
self.assertIsInstance(conn, MyConnection)
878+
869879

870880
if __name__ == "__main__":
871881
test_env.run_test_cases()

utils/templates/pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def _set_connection_type(self, conn_class):
409409
conn_class = connection_module.Connection
410410
elif not issubclass(
411411
conn_class, connection_module.Connection
412-
) or issubclass(connection_module.AsyncConnection):
412+
) or issubclass(conn_class, connection_module.AsyncConnection):
413413
errors._raise_err(errors.ERR_INVALID_CONN_CLASS)
414414
self._connection_type = conn_class
415415
self._connection_method = oracledb.connect

0 commit comments

Comments
 (0)