From 6c08dba5176606e8a62dd108bb6c9467d678d2f4 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 22 Dec 2023 09:43:45 +0100 Subject: [PATCH] Fixed #35054 -- Fixed crash on Oracle when fetching JSONFields with oracledb 2.0.0. --- django/db/backends/oracle/base.py | 6 +++++- docs/releases/5.0.1.txt | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index a5e7f97df01c..2d91468d25b2 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -453,7 +453,7 @@ def _get_decimal_converter(precision, scale): def _output_type_handler(cursor, name, defaultType, length, precision, scale): """ Called for each db column fetched from cursors. Return numbers as the - appropriate Python type. + appropriate Python type, and NCLOB with JSON as strings. """ if defaultType == Database.NUMBER: if scale == -127: @@ -483,6 +483,10 @@ def _output_type_handler(cursor, name, defaultType, length, precision, scale): arraysize=cursor.arraysize, outconverter=outconverter, ) + # oracledb 2.0.0+ returns NLOB columns with IS JSON constraints as + # dicts. Use a no-op converter to avoid this. + elif defaultType == Database.DB_TYPE_NCLOB: + return cursor.var(Database.DB_TYPE_NCLOB, arraysize=cursor.arraysize) def _format_params(self, params): try: diff --git a/docs/releases/5.0.1.txt b/docs/releases/5.0.1.txt index 79fbf9a0a18b..592454e89344 100644 --- a/docs/releases/5.0.1.txt +++ b/docs/releases/5.0.1.txt @@ -27,3 +27,5 @@ Bugfixes * Fixed a regression in Django 5.0 where admin fields on the same line could overflow the page and become non-interactive (:ticket:`35012`). + +* Added compatibility for ``oracledb`` 2.0.0 (:ticket:`35054`).