Skip to content

Commit

Permalink
Fixed backends.oracle.tests.TransactionalTests.test_hidden_no_data_fo…
Browse files Browse the repository at this point in the history
…und_exception() on oracledb >= 2.1.2.

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

oracle/python-oracledb#321
  • Loading branch information
felixxm authored and sarahboyce committed Apr 15, 2024
1 parent 42bc81b commit dd23821
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions django/db/backends/oracle/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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):
Expand Down Expand Up @@ -345,6 +346,10 @@ def oracle_version(self):
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:
"""
Expand Down
11 changes: 11 additions & 0 deletions django/db/backends/oracle/features.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -137,6 +138,16 @@ def django_test_skips(self):
},
}
)
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
Expand Down
2 changes: 2 additions & 0 deletions django/db/backends/oracle/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def fetch_returned_insert_columns(self, cursor, returning_params):
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 "
Expand Down

0 comments on commit dd23821

Please sign in to comment.