def setinputsizes(self, *args: Any, **kwargs: Any) -> Any:
return self._cursor.setinputsizes(*args, **kwargs)
- def _aenter_cursor(self, cursor: AsyncCursor) -> AsyncCursor:
- try:
- return cursor.__enter__()
- except Exception as error:
- self._adapt_connection._handle_exception(error)
-
async def _execute_async(self, operation, parameters):
# override to not use mutex, oracledb already has a mutex
supports_statement_cache = True
execution_ctx_cls = OracleExecutionContextAsync_oracledb
- _min_version = (2,)
+ _min_version = (2, 0, 1)
# thick_mode mode is not supported by asyncio, oracledb will raise
@classmethod
mysql = ["mysqlclient>=1.4.0"]
mysql-connector = ["mysql-connector-python"]
mariadb-connector = ["mariadb>=1.0.1,!=1.1.2,!=1.1.5,!=1.1.10"]
-oracle = ["oracledb>=1.0.1"]
+oracle = ["oracledb>=2.0.1"]
oracle-cxoracle = ["cx_oracle>=8"]
-oracle-oracledb = ["oracledb>=1.0.1"]
+oracle-oracledb = ["oracledb>=2.0.1"]
postgresql = ["psycopg>=3.0.7,!=3.1.15"]
postgresql-pg8000 = ["pg8000>=1.29.3"]
postgresql-asyncpg = [
from sqlalchemy.testing import assert_raises_message
from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import AssertsExecutionResults
+from sqlalchemy.testing import async_test
from sqlalchemy.testing import config
from sqlalchemy.testing import engines
from sqlalchemy.testing import eq_
from sqlalchemy.testing.schema import pep435_enum
from sqlalchemy.testing.schema import Table
from sqlalchemy.testing.suite import test_select
+from sqlalchemy.util import greenlet_spawn
class CxOracleDialectTest(fixtures.TestBase):
dialect = oracledb.OracleDialect_oracledb(dbapi=Mock(version="7.1.0"))
eq_(dialect.oracledb_ver, (7, 1, 0))
+ def test_async_minimum_version(self):
+ with expect_raises_message(
+ exc.InvalidRequestError,
+ r"oracledb version \(2, 0, 1\) and above are supported",
+ ):
+ oracledb.OracleDialectAsync_oracledb(dbapi=Mock(version="2.0.0"))
+
+ dialect = oracledb.OracleDialectAsync_oracledb(
+ dbapi=Mock(version="2.0.1")
+ )
+ eq_(dialect.oracledb_ver, (2, 0, 1))
+
def test_get_dialect(self):
u = url.URL.create("oracle://")
d = oracledb.OracleDialect_oracledb.get_dialect_cls(u)
e = create_engine("oracle+oracledb_async://")
is_true(isinstance(e.dialect, oracledb.OracleDialectAsync_oracledb))
+ @async_test
+ async def test_async_cursor_enters_asynchronously(self):
+ """test #13420"""
+
+ adapt_connection = Mock()
+
+ underlying_cursor = Mock()
+
+ async def aenter(*arg, **kw):
+ return underlying_cursor
+
+ underlying_cursor.__aenter__ = Mock(side_effect=aenter)
+ underlying_cursor.__enter__ = Mock(
+ side_effect=AssertionError("sync __enter__ should not be called")
+ )
+
+ adapt_connection._connection.cursor = Mock(
+ return_value=underlying_cursor
+ )
+
+ cursor = await greenlet_spawn(
+ oracledb.AsyncAdapt_oracledb_cursor, adapt_connection
+ )
+
+ is_(cursor._cursor, underlying_cursor)
+ underlying_cursor.__aenter__.assert_called_once()
+ underlying_cursor.__enter__.assert_not_called()
+
class OracledbMode(fixtures.TestBase):
__backend__ = True