Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 Morales authored November 11, 2010

Showing 1 changed file with 22 additions and 0 deletions. Show diff stats Hide diff stats

  1. 22  django/db/backends/oracle/base.py
22  django/db/backends/oracle/base.py
@@ -399,6 +399,28 @@ def _cursor(self):
399 399
     def _savepoint_commit(self, sid):
400 400
         pass
401 401
 
  402
+    def _commit(self):
  403
+        if self.connection is not None:
  404
+            try:
  405
+                return self.connection.commit()
  406
+            except Database.IntegrityError, e:
  407
+                # In case cx_Oracle implements (now or in a future version)
  408
+                # raising this specific exception
  409
+                raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
  410
+            except Database.DatabaseError, e:
  411
+                # cx_Oracle 5.0.4 raises a cx_Oracle.DatabaseError exception
  412
+                # with the following attributes and values:
  413
+                #  code = 2091
  414
+                #  message = 'ORA-02091: transaction rolled back
  415
+                #            'ORA-02291: integrity constraint (TEST_DJANGOTEST.SYS
  416
+                #               _C00102056) violated - parent key not found'
  417
+                # We convert that particular case to our IntegrityError exception
  418
+                x = e.args[0]
  419
+                if hasattr(x, 'code') and hasattr(x, 'message') \
  420
+                   and x.code == 2091 and 'ORA-02291' in x.message:
  421
+                    raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
  422
+                raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
  423
+
402 424
 
403 425
 class OracleParam(object):
404 426
     """

0 notes on commit f91b41f

Please sign in to comment.
Something went wrong with that request. Please try again.