mirror of https://github.com/django/django.git
Removed DatabaseError and IntegrityError declarations from database backends.
Unused since 11ee9746a0
.
This commit is contained in:
parent
6fe846a8f0
commit
85f2bba7eb
|
@ -26,14 +26,6 @@ def ignore(*args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class DatabaseError(Exception):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class IntegrityError(DatabaseError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseOperations(BaseDatabaseOperations):
|
class DatabaseOperations(BaseDatabaseOperations):
|
||||||
quote_name = complain
|
quote_name = complain
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,6 @@ if (version < (1, 2, 1) or (
|
||||||
raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)
|
raise ImproperlyConfigured("MySQLdb-1.2.1p2 or newer is required; you have %s" % Database.__version__)
|
||||||
|
|
||||||
|
|
||||||
DatabaseError = Database.DatabaseError
|
|
||||||
IntegrityError = Database.IntegrityError
|
|
||||||
|
|
||||||
|
|
||||||
def adapt_datetime_warn_on_aware_datetime(value, conv):
|
def adapt_datetime_warn_on_aware_datetime(value, conv):
|
||||||
# Remove this function and rely on the default adapter in Django 2.0.
|
# Remove this function and rely on the default adapter in Django 2.0.
|
||||||
if settings.USE_TZ and timezone.is_aware(value):
|
if settings.USE_TZ and timezone.is_aware(value):
|
||||||
|
|
|
@ -63,9 +63,6 @@ from .operations import DatabaseOperations # NOQA isort:skip
|
||||||
from .schema import DatabaseSchemaEditor # NOQA isort:skip
|
from .schema import DatabaseSchemaEditor # NOQA isort:skip
|
||||||
from .utils import Oracle_datetime, convert_unicode # NOQA isort:skip
|
from .utils import Oracle_datetime, convert_unicode # NOQA isort:skip
|
||||||
|
|
||||||
DatabaseError = Database.DatabaseError
|
|
||||||
IntegrityError = Database.IntegrityError
|
|
||||||
|
|
||||||
|
|
||||||
class _UninitializedOperatorsDescriptor(object):
|
class _UninitializedOperatorsDescriptor(object):
|
||||||
|
|
||||||
|
@ -241,7 +238,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s"
|
cursor.execute("SELECT 1 FROM DUAL WHERE DUMMY %s"
|
||||||
% self._standard_operators['contains'],
|
% self._standard_operators['contains'],
|
||||||
['X'])
|
['X'])
|
||||||
except DatabaseError:
|
except Database.DatabaseError:
|
||||||
self.operators = self._likec_operators
|
self.operators = self._likec_operators
|
||||||
self.pattern_ops = self._likec_pattern_ops
|
self.pattern_ops = self._likec_pattern_ops
|
||||||
else:
|
else:
|
||||||
|
@ -479,7 +476,7 @@ class FormatStylePlaceholderCursor(object):
|
||||||
return self.cursor.execute(query, self._param_generator(params))
|
return self.cursor.execute(query, self._param_generator(params))
|
||||||
except Database.DatabaseError as e:
|
except Database.DatabaseError as e:
|
||||||
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
||||||
if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError):
|
if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, Database.IntegrityError):
|
||||||
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -498,7 +495,7 @@ class FormatStylePlaceholderCursor(object):
|
||||||
return self.cursor.executemany(query, [self._param_generator(p) for p in formatted])
|
return self.cursor.executemany(query, [self._param_generator(p) for p in formatted])
|
||||||
except Database.DatabaseError as e:
|
except Database.DatabaseError as e:
|
||||||
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
||||||
if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, IntegrityError):
|
if hasattr(e.args[0], 'code') and e.args[0].code == 1400 and not isinstance(e, Database.IntegrityError):
|
||||||
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
six.reraise(utils.IntegrityError, utils.IntegrityError(*tuple(e.args)), sys.exc_info()[2])
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,6 @@ from .schema import DatabaseSchemaEditor # NOQA isort:skip
|
||||||
from .utils import utc_tzinfo_factory # NOQA isort:skip
|
from .utils import utc_tzinfo_factory # NOQA isort:skip
|
||||||
from .version import get_version # NOQA isort:skip
|
from .version import get_version # NOQA isort:skip
|
||||||
|
|
||||||
DatabaseError = Database.DatabaseError
|
|
||||||
IntegrityError = Database.IntegrityError
|
|
||||||
|
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
|
psycopg2.extensions.register_type(psycopg2.extensions.UNICODEARRAY)
|
||||||
|
@ -239,7 +236,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
nodb_connection = super(DatabaseWrapper, self)._nodb_connection
|
nodb_connection = super(DatabaseWrapper, self)._nodb_connection
|
||||||
try:
|
try:
|
||||||
nodb_connection.ensure_connection()
|
nodb_connection.ensure_connection()
|
||||||
except (DatabaseError, WrappedDatabaseError):
|
except (Database.DatabaseError, WrappedDatabaseError):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"Normally Django will use a connection to the 'postgres' database "
|
"Normally Django will use a connection to the 'postgres' database "
|
||||||
"to avoid running initialization queries against the production "
|
"to avoid running initialization queries against the production "
|
||||||
|
|
|
@ -45,9 +45,6 @@ from .introspection import DatabaseIntrospection # isort:skip
|
||||||
from .operations import DatabaseOperations # isort:skip
|
from .operations import DatabaseOperations # isort:skip
|
||||||
from .schema import DatabaseSchemaEditor # isort:skip
|
from .schema import DatabaseSchemaEditor # isort:skip
|
||||||
|
|
||||||
DatabaseError = Database.DatabaseError
|
|
||||||
IntegrityError = Database.IntegrityError
|
|
||||||
|
|
||||||
|
|
||||||
def adapt_datetime_warn_on_aware_datetime(value):
|
def adapt_datetime_warn_on_aware_datetime(value):
|
||||||
# Remove this function and rely on the default adapter in Django 2.0.
|
# Remove this function and rely on the default adapter in Django 2.0.
|
||||||
|
|
Loading…
Reference in New Issue