Skip to content

Commit

Permalink
Fix regression when using a connection type when creating a pool.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-tuininga committed Dec 19, 2023
1 parent 3aad0aa commit 9645d4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/oracledb/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def _set_connection_type(self, conn_class):
conn_class = connection_module.Connection
elif not issubclass(
conn_class, connection_module.Connection
) or issubclass(connection_module.AsyncConnection):
) or issubclass(conn_class, connection_module.AsyncConnection):
errors._raise_err(errors.ERR_INVALID_CONN_CLASS)
self._connection_type = conn_class
self._connection_method = oracledb.connect
Expand Down
10 changes: 10 additions & 0 deletions tests/test_2400_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,16 @@ def test_2434_invalid_pool_class(self):
pool_class=int,
)

def test_2435_pool_with_connectiontype(self):
"2435 - test creating a pool with a subclassed connection type"

class MyConnection(oracledb.Connection):
pass

pool = test_env.get_pool(connectiontype=MyConnection)
with pool.acquire() as conn:
self.assertIsInstance(conn, MyConnection)


if __name__ == "__main__":
test_env.run_test_cases()
2 changes: 1 addition & 1 deletion utils/templates/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def _set_connection_type(self, conn_class):
conn_class = connection_module.Connection
elif not issubclass(
conn_class, connection_module.Connection
) or issubclass(connection_module.AsyncConnection):
) or issubclass(conn_class, connection_module.AsyncConnection):
errors._raise_err(errors.ERR_INVALID_CONN_CLASS)
self._connection_type = conn_class
self._connection_method = oracledb.connect
Expand Down

0 comments on commit 9645d4f

Please sign in to comment.