Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@mboersma mboersma authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 django/db/backends/oracle/base.py
View
16 django/db/backends/oracle/base.py
@@ -354,7 +354,13 @@ def execute(self, query, params=None):
query = query[:-1]
query = smart_str(query, self.charset) % tuple(args)
self._guess_input_sizes([params])
- return Database.Cursor.execute(self, query, self._param_generator(params))
+ try:
+ return Database.Cursor.execute(self, query, self._param_generator(params))
+ except DatabaseError, e:
+ # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
+ if e.message.code == 1400 and type(e) != IntegrityError:
+ e = IntegrityError(e.message)
+ raise e
def executemany(self, query, params=None):
try:
@@ -371,7 +377,13 @@ def executemany(self, query, params=None):
query = smart_str(query, self.charset) % tuple(args)
formatted = [self._format_params(i) for i in params]
self._guess_input_sizes(formatted)
- return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
+ try:
+ return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
+ except DatabaseError, e:
+ # cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
+ if e.message.code == 1400 and type(e) != IntegrityError:
+ e = IntegrityError(e.message)
+ raise e
def fetchone(self):
row = Database.Cursor.fetchone(self)
Please sign in to comment.
Something went wrong with that request. Please try again.