diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2010-10-23 00:01:22 +0000 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2010-10-23 00:01:22 +0000 |
| commit | cfdad9ed86c8408fe69fd0a946419f9c8aa265c8 (patch) | |
| tree | dbb57d6006e3c27ee9e5761a2a76b3afe67235e7 /django/db | |
| parent | cad4feabad2a577e3ffb709679851bda74cc585e (diff) | |
Fixed #14223 -- Extended unification of exception raised in presence of integrity constraint violations.
The unification had been introduced in r12352 and native backend exceptions still
slipped through in cases that end in connection.commit() call. Thanks Alex,
Jacob and Carl for reviewing.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14320 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/postgresql/base.py | 7 | ||||
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py index 5e47a37d3f..12631785bc 100644 --- a/django/db/backends/postgresql/base.py +++ b/django/db/backends/postgresql/base.py @@ -153,6 +153,13 @@ class DatabaseWrapper(BaseDatabaseWrapper): cursor.execute("SET client_encoding to 'UNICODE'") return UnicodeCursorWrapper(cursor, 'utf-8') + def _commit(self): + if self.connection is not None: + try: + return self.connection.commit() + except Database.IntegrityError, e: + raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] + def typecast_string(s): """ Cast all returned strings to unicode strings. diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 9e5fb53d56..71ec58153a 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -192,3 +192,10 @@ class DatabaseWrapper(BaseDatabaseWrapper): finally: self.isolation_level = level self.features.uses_savepoints = bool(level) + + def _commit(self): + if self.connection is not None: + try: + return self.connection.commit() + except Database.IntegrityError, e: + raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2] |
