Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed get_or_create test case for Oracle by re-raising the more speci…

…fic IntegrityError for "ORA-01400: Cannot insert NULL into [table.col]"

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8545 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1aa48898085ea16915877cc139e238a74e3f554b 1 parent 78d13fb
Matt Boersma authored August 25, 2008

Showing 1 changed file with 14 additions and 2 deletions. Show diff stats Hide diff stats

  1. 16  django/db/backends/oracle/base.py
16  django/db/backends/oracle/base.py
@@ -354,7 +354,13 @@ def execute(self, query, params=None):
354 354
             query = query[:-1]
355 355
         query = smart_str(query, self.charset) % tuple(args)
356 356
         self._guess_input_sizes([params])
357  
-        return Database.Cursor.execute(self, query, self._param_generator(params))
  357
+        try:
  358
+            return Database.Cursor.execute(self, query, self._param_generator(params))
  359
+        except DatabaseError, e:
  360
+            # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
  361
+            if e.message.code == 1400 and type(e) != IntegrityError:
  362
+                e = IntegrityError(e.message)
  363
+            raise e
358 364
 
359 365
     def executemany(self, query, params=None):
360 366
         try:
@@ -371,7 +377,13 @@ def executemany(self, query, params=None):
371 377
         query = smart_str(query, self.charset) % tuple(args)
372 378
         formatted = [self._format_params(i) for i in params]
373 379
         self._guess_input_sizes(formatted)
374  
-        return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
  380
+        try:
  381
+            return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
  382
+        except DatabaseError, e:
  383
+            # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
  384
+            if e.message.code == 1400 and type(e) != IntegrityError:
  385
+                e = IntegrityError(e.message)
  386
+            raise e
375 387
 
376 388
     def fetchone(self):
377 389
         row = Database.Cursor.fetchone(self)

0 notes on commit 1aa4889

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