diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py index 5a9c02e032a..1b219e620c9 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):