From 26aae5614487f58ddb1df5726224393887373ecd Mon Sep 17 00:00:00 2001 From: Albert Defler Date: Sat, 17 Feb 2024 12:22:53 +0000 Subject: [PATCH] Refs #34060 -- Fixed JSONField __exact lookup for primitivies on Oracle 21c+. Regression in c991602ce5798385261381025c06698d7fd30dc5. Co-Authored-By: Mariusz Felisiak --- django/db/models/fields/json.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py index 5a9c02e032..1b219e620c 100644 --- a/django/db/models/fields/json.py +++ b/django/db/models/fields/json.py @@ -313,7 +313,10 @@ class JSONExact(lookups.Exact): def as_oracle(self, compiler, connection): lhs, lhs_params = self.process_lhs(compiler, connection) rhs, rhs_params = self.process_rhs(compiler, connection) - return f"JSON_EQUAL({lhs}, {rhs})", (*lhs_params, *rhs_params) + if connection.features.supports_primitives_in_json_field: + lhs = f"JSON({lhs})" + rhs = f"JSON({rhs})" + return f"JSON_EQUAL({lhs}, {rhs} ERROR ON ERROR)", (*lhs_params, *rhs_params) class JSONIContains(CaseInsensitiveMixin, lookups.IContains):