Fixed backends.oracle.tests.TransactionalTests.test_hidden_no_data_found_exception() on oracledb >= 2.1.2.

python-oracledb 2.1.2+ no longer hides 'ORA-1403: no data found'
exceptions raised in database triggers:

https://github.com/oracle/python-oracledb/issues/321
This commit is contained in:
Mariusz Felisiak 2024-04-14 13:21:44 +02:00 committed by Sarah Boyce
parent 42bc81b1b6
commit dd23821208
3 changed files with 18 additions and 0 deletions

View File

@ -19,6 +19,7 @@ from django.db.backends.utils import debug_transaction
from django.utils.asyncio import async_unsafe
from django.utils.encoding import force_bytes, force_str
from django.utils.functional import cached_property
from django.utils.version import get_version_tuple
def _setup_environment(environ):
@ -345,6 +346,10 @@ class DatabaseWrapper(BaseDatabaseWrapper):
with self.temporary_connection():
return tuple(int(x) for x in self.connection.version.split("."))
@cached_property
def oracledb_version(self):
return get_version_tuple(Database.__version__)
class OracleParam:
"""

View File

@ -1,5 +1,6 @@
from django.db import DatabaseError, InterfaceError
from django.db.backends.base.features import BaseDatabaseFeatures
from django.db.backends.oracle.oracledb_any import is_oracledb
from django.utils.functional import cached_property
@ -137,6 +138,16 @@ class DatabaseFeatures(BaseDatabaseFeatures):
},
}
)
if is_oracledb and self.connection.oracledb_version >= (2, 1, 2):
skips.update(
{
"python-oracledb 2.1.2+ no longer hides 'ORA-1403: no data found' "
"exceptions raised in database triggers.": {
"backends.oracle.tests.TransactionalTests."
"test_hidden_no_data_found_exception"
},
},
)
return skips
@cached_property

View File

@ -295,6 +295,8 @@ END;
columns = []
for param in returning_params:
value = param.get_value()
# Can be removed when cx_Oracle is no longer supported and
# python-oracle 2.1.2 becomes the minimum supported version.
if value == []:
raise DatabaseError(
"The database did not return a new row id. Probably "