Refs #33817 -- Corrected errors raised when Oracle driver is not installed.

oracledb_any should reraise ImportError instead of raising
ImproperlyConfigured.
This commit is contained in:
Mariusz Felisiak 2024-09-09 10:39:15 +02:00 committed by Sarah Boyce
parent e161bd4657
commit cdbd31960e
2 changed files with 6 additions and 3 deletions

View File

@ -14,13 +14,17 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.db import IntegrityError from django.db import IntegrityError
from django.db.backends.base.base import BaseDatabaseWrapper from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.oracle.oracledb_any import oracledb as Database
from django.db.backends.utils import debug_transaction from django.db.backends.utils import debug_transaction
from django.utils.asyncio import async_unsafe from django.utils.asyncio import async_unsafe
from django.utils.encoding import force_bytes, force_str from django.utils.encoding import force_bytes, force_str
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.version import get_version_tuple from django.utils.version import get_version_tuple
try:
from django.db.backends.oracle.oracledb_any import oracledb as Database
except ImportError as e:
raise ImproperlyConfigured(f"Error loading oracledb module: {e}")
def _setup_environment(environ): def _setup_environment(environ):
# Cygwin requires some special voodoo to set the environment variables # Cygwin requires some special voodoo to set the environment variables

View File

@ -1,6 +1,5 @@
import warnings import warnings
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import RemovedInDjango60Warning from django.utils.deprecation import RemovedInDjango60Warning
try: try:
@ -18,4 +17,4 @@ except ImportError as e:
) )
is_oracledb = False is_oracledb = False
except ImportError: except ImportError:
raise ImproperlyConfigured(f"Error loading oracledb module: {e}") raise e from None