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

Backport of da92ec7962 from master
This commit is contained in:
Mariusz Felisiak 2018-09-16 12:45:34 +02:00
parent 4c5a8c6f50
commit 430966c2fc
No known key found for this signature in database
GPG Key ID: 2EF56372BA48CD1B
2 changed files with 5 additions and 1 deletions

View File

@ -222,7 +222,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`).