diff options
author | Johannes Hoppe <info@johanneshoppe.com> | 2019-06-10 13:56:50 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-07-08 08:53:08 +0200 |
commit | bc91f27a86090b4c688b56cd4e37f95eebe6e969 (patch) | |
tree | 52d2e64c5e468f1aeb35ea89b244e38f17239aff /django/db/backends/oracle/utils.py | |
parent | 34a88b21dae71a26a9b136b599e5cbcf817eae16 (diff) | |
download | django-bc91f27a86090b4c688b56cd4e37f95eebe6e969.tar.gz |
Refs #29444 -- Added support for fetching a returned non-integer insert values on Oracle.
This is currently not actively used, since the ORM will ask the
SQL compiler to only return auto fields.
Diffstat (limited to 'django/db/backends/oracle/utils.py')
-rw-r--r-- | django/db/backends/oracle/utils.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/django/db/backends/oracle/utils.py b/django/db/backends/oracle/utils.py index 02e3f754a8..64e69136bf 100644 --- a/django/db/backends/oracle/utils.py +++ b/django/db/backends/oracle/utils.py @@ -3,14 +3,26 @@ import datetime from .base import Database -class InsertIdVar: +class InsertVar: """ A late-binding cursor variable that can be passed to Cursor.execute as a parameter, in order to receive the id of the row created by an insert statement. """ + types = { + 'FloatField': Database.NATIVE_FLOAT, + 'CharField': str, + 'DateTimeField': Database.TIMESTAMP, + 'DateField': Database.DATETIME, + 'DecimalField': Database.NUMBER, + } + + def __init__(self, field): + internal_type = getattr(field, 'target_field', field).get_internal_type() + self.db_type = self.types.get(internal_type, int) + def bind_parameter(self, cursor): - param = cursor.cursor.var(int) + param = cursor.cursor.var(self.db_type) cursor._insert_id_var = param return param |