mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #34060 -- Fixed migrations crash when adding check constraints with JSONField __exact lookup on Oracle.
This commit is contained in:
committed by
Mariusz Felisiak
parent
22285d366c
commit
c991602ce5
@@ -347,9 +347,10 @@ END;
|
||||
def lookup_cast(self, lookup_type, internal_type=None):
|
||||
if lookup_type in ("iexact", "icontains", "istartswith", "iendswith"):
|
||||
return "UPPER(%s)"
|
||||
if (
|
||||
lookup_type != "isnull" and internal_type in ("BinaryField", "TextField")
|
||||
) or (lookup_type == "exact" and internal_type == "JSONField"):
|
||||
if lookup_type != "isnull" and internal_type in (
|
||||
"BinaryField",
|
||||
"TextField",
|
||||
):
|
||||
return "DBMS_LOB.SUBSTR(%s)"
|
||||
return "%s"
|
||||
|
||||
|
||||
@@ -106,6 +106,13 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
"test_group_by_nested_expression_with_params",
|
||||
}
|
||||
)
|
||||
if not is_psycopg3:
|
||||
expected_failures.update(
|
||||
{
|
||||
"constraints.tests.CheckConstraintTests."
|
||||
"test_validate_jsonfield_exact",
|
||||
}
|
||||
)
|
||||
return expected_failures
|
||||
|
||||
@cached_property
|
||||
|
||||
@@ -310,6 +310,11 @@ class JSONExact(lookups.Exact):
|
||||
rhs %= tuple(func)
|
||||
return rhs, rhs_params
|
||||
|
||||
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)
|
||||
|
||||
|
||||
class JSONIContains(CaseInsensitiveMixin, lookups.IContains):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user