summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2010-11-11 04:37:37 +0000
committerRamiro Morales <cramm0@gmail.com>2010-11-11 04:37:37 +0000
commit0f065d346dc4814d42374c9069ef0e232f6d9b7b (patch)
tree26f6192f00fc1609663827cbf0b8b1ec66f7fdd5
parent7335388be2d2dbccf82c15f86121698487032fd6 (diff)
[1.2.X] Implemented changes made in r14320 in the Oracle backend. Thanks Russell for reviewing the proposed fix.
Backport of [14510] from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/oracle/base.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index a175c3933a..919c862621 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -396,6 +396,28 @@ class DatabaseWrapper(BaseDatabaseWrapper):
def _savepoint_commit(self, sid):
pass
+ def _commit(self):
+ if self.connection is not None:
+ try:
+ return self.connection.commit()
+ except Database.IntegrityError, e:
+ # In case cx_Oracle implements (now or in a future version)
+ # raising this specific exception
+ raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
+ except Database.DatabaseError, e:
+ # cx_Oracle 5.0.4 raises a cx_Oracle.DatabaseError exception
+ # with the following attributes and values:
+ # code = 2091
+ # message = 'ORA-02091: transaction rolled back
+ # 'ORA-02291: integrity constraint (TEST_DJANGOTEST.SYS
+ # _C00102056) violated - parent key not found'
+ # We convert that particular case to our IntegrityError exception
+ x = e.args[0]
+ if hasattr(x, 'code') and hasattr(x, 'message') \
+ and x.code == 2091 and 'ORA-02291' in x.message:
+ raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
+ raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
+
class OracleParam(object):
"""