Author: ramiro
Date: 2010-11-10 22:36:20 -0600 (Wed, 10 Nov 2010)
New Revision: 14510

Modified:
   django/trunk/django/db/backends/oracle/base.py
Log:
Implemented changes made in r14320 in the Oracle backend. Thanks Russell for 
reviewing the proposed fix.

Modified: django/trunk/django/db/backends/oracle/base.py
===================================================================
--- django/trunk/django/db/backends/oracle/base.py      2010-11-09 17:42:38 UTC 
(rev 14509)
+++ django/trunk/django/db/backends/oracle/base.py      2010-11-11 04:36:20 UTC 
(rev 14510)
@@ -399,7 +399,29 @@
     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):
     """
     Wrapper object for formatting parameters for Oracle. If the string

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to