Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #3450 -- Exposed IntegrityError in a backend-neutral fashion. T…

…his is a

useful error to be able to catch explicitly. Thanks, enlight.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5076 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b3e0b59def4b6125f5a946d6a87b9b8997da7826 1 parent e23abab
@malcolmt malcolmt authored
View
1  AUTHORS
@@ -85,6 +85,7 @@ answer newbie questions, and generally made Django that much better:
Jeremy Dunck <http://dunck.us/>
Andy Dustman <farcepest@gmail.com>
Clint Ecker
+ enlight
Enrico <rico.bl@gmail.com>
Ludvig Ericson <ludvig.ericson@gmail.com>
Dirk Eschler <dirk.eschler@gmx.net>
View
3  django/db/__init__.py
@@ -2,7 +2,7 @@
from django.core import signals
from django.dispatch import dispatcher
-__all__ = ('backend', 'connection', 'DatabaseError')
+__all__ = ('backend', 'connection', 'DatabaseError', 'IntegrityError')
if not settings.DATABASE_ENGINE:
settings.DATABASE_ENGINE = 'dummy'
@@ -29,6 +29,7 @@
connection = backend.DatabaseWrapper(**settings.DATABASE_OPTIONS)
DatabaseError = backend.DatabaseError
+IntegrityError = backend.IntegrityError
# Register an event that closes the database connection
# when a Django request is finished.
View
1  django/db/backends/ado_mssql/base.py
@@ -17,6 +17,7 @@
mx = None
DatabaseError = Database.DatabaseError
+IntegrityError = Database.IntegrityError
# We need to use a special Cursor class because adodbapi expects question-mark
# param style, but Django expects "%s". This cursor converts question marks to
View
3  django/db/backends/dummy/base.py
@@ -15,6 +15,9 @@ def complain(*args, **kwargs):
class DatabaseError(Exception):
pass
+class IntegrityError(DatabaseError):
+ pass
+
class DatabaseWrapper:
cursor = complain
_commit = complain
View
1  django/db/backends/mysql/base.py
@@ -25,6 +25,7 @@
import re
DatabaseError = Database.DatabaseError
+IntegrityError = Database.IntegrityError
# MySQLdb-1.2.1 supports the Python boolean type, and only uses datetime
# module for time-related columns; older versions could have used mx.DateTime
View
1  django/db/backends/mysql_old/base.py
@@ -16,6 +16,7 @@
import re
DatabaseError = Database.DatabaseError
+IntegrityError = Database.IntegrityError
django_conversions = conversions.copy()
django_conversions.update({
View
1  django/db/backends/oracle/base.py
@@ -12,6 +12,7 @@
raise ImproperlyConfigured, "Error loading cx_Oracle module: %s" % e
DatabaseError = Database.Error
+IntegrityError = Database.IntegrityError
try:
# Only exists in Python 2.4+
View
1  django/db/backends/postgresql/base.py
@@ -12,6 +12,7 @@
raise ImproperlyConfigured, "Error loading psycopg module: %s" % e
DatabaseError = Database.DatabaseError
+IntegrityError = Database.IntegrityError
try:
# Only exists in Python 2.4+
View
1  django/db/backends/postgresql_psycopg2/base.py
@@ -12,6 +12,7 @@
raise ImproperlyConfigured, "Error loading psycopg2 module: %s" % e
DatabaseError = Database.DatabaseError
+IntegrityError = Database.IntegrityError
try:
# Only exists in Python 2.4+
View
1  django/db/backends/sqlite3/base.py
@@ -18,6 +18,7 @@
raise ImproperlyConfigured, "Error loading %s module: %s" % (module, e)
DatabaseError = Database.DatabaseError
+IntegrityError = Database.IntegrityError
Database.register_converter("bool", lambda s: str(s) == '1')
Database.register_converter("time", util.typecast_time)
Please sign in to comment.
Something went wrong with that request. Please try again.