Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implemented changes made in r14320 in the Oracle backend. Thanks Russ…

…ell for reviewing the proposed fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14510 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f91b41fe338d691bc3a6a8a8fc1509c9b61e7d18 1 parent cab434e
@ramiro ramiro authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 django/db/backends/oracle/base.py
View
22 django/db/backends/oracle/base.py
@@ -399,6 +399,28 @@ def _cursor(self):
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):
"""
Please sign in to comment.
Something went wrong with that request. Please try again.