Fixed re-raising of ORA-01400 as an IntegrityError in a way that works on Python 2.3 and 2.4 as well.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8965 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3239849174
commit
1b39622327
|
@ -361,8 +361,8 @@ class FormatStylePlaceholderCursor(Database.Cursor):
|
||||||
return Database.Cursor.execute(self, query, self._param_generator(params))
|
return Database.Cursor.execute(self, query, self._param_generator(params))
|
||||||
except DatabaseError, e:
|
except DatabaseError, e:
|
||||||
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
||||||
if e.message.code == 1400 and type(e) != IntegrityError:
|
if e.args[0].code == 1400 and not isinstance(e, IntegrityError):
|
||||||
e = IntegrityError(e.message)
|
e = IntegrityError(e.args[0])
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def executemany(self, query, params=None):
|
def executemany(self, query, params=None):
|
||||||
|
@ -384,8 +384,8 @@ class FormatStylePlaceholderCursor(Database.Cursor):
|
||||||
return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
|
return Database.Cursor.executemany(self, query, [self._param_generator(p) for p in formatted])
|
||||||
except DatabaseError, e:
|
except DatabaseError, e:
|
||||||
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
# cx_Oracle <= 4.4.0 wrongly raises a DatabaseError for ORA-01400.
|
||||||
if e.message.code == 1400 and type(e) != IntegrityError:
|
if e.args[0].code == 1400 and not isinstance(e, IntegrityError):
|
||||||
e = IntegrityError(e.message)
|
e = IntegrityError(e.args[0])
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def fetchone(self):
|
def fetchone(self):
|
||||||
|
|
Loading…
Reference in New Issue