Fixed #29759 -- Fixed crash on Oracle when fetching a returned insert id with cx_Oracle 7.

This commit is contained in:
Mariusz Felisiak 2018-09-16 12:45:34 +02:00 committed by GitHub
parent f87f9c5f63
commit da92ec7962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -226,7 +226,9 @@ END;
def fetch_returned_insert_id(self, cursor):
try:
return int(cursor._insert_id_var.getvalue())
value = cursor._insert_id_var.getvalue()
# cx_Oracle < 7 returns value, >= 7 returns list with single value.
return int(value[0] if isinstance(value, list) else value)
except (IndexError, TypeError):
# cx_Oracle < 6.3 returns None, >= 6.3 raises IndexError.
raise DatabaseError(

View File

@ -17,3 +17,5 @@ Bugfixes
* Made migrations detect changes to ``Meta.default_related_name``
(:ticket:`29755`).
* Added compatibility for ``cx_Oracle`` 7 (:ticket:`29759`).