summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-08 19:34:30 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-05-08 19:35:20 +0200
commite0d8981139cd329962e509efb575fdfb2dad4073 (patch)
tree617b72e8c24736e29597b1783514dc7a512128bf /django
parentdc3b8190ed2b01e450c81df28023f0b6352b4a27 (diff)
[4.2.x] Fixed #34544 -- Avoided DBMS_LOB.SUBSTR() wrapping with IS NULL condition on Oracle.
Regression in 09ffc5c1212d4ced58b708cbbf3dfbfb77b782ca. Thanks Michael Smith for the report. This also reverts commit 1e4da439556cdd69eb9f91e07f99cf77997e70d2. Backport of 1586a09b7949bbb7b0d84cb74ce1cadc25cbb355 from main
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/oracle/operations.py10
-rw-r--r--django/db/backends/postgresql/features.py3
2 files changed, 6 insertions, 7 deletions
diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
index d34ca23bae..64b1f82071 100644
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -296,12 +296,6 @@ END;
columns.append(value[0])
return tuple(columns)
- def field_cast_sql(self, db_type, internal_type):
- if db_type and db_type.endswith("LOB") and internal_type != "JSONField":
- return "DBMS_LOB.SUBSTR(%s)"
- else:
- return "%s"
-
def no_limit_value(self):
return None
@@ -344,7 +338,9 @@ END;
def lookup_cast(self, lookup_type, internal_type=None):
if lookup_type in ("iexact", "icontains", "istartswith", "iendswith"):
return "UPPER(%s)"
- if internal_type == "JSONField" and lookup_type == "exact":
+ if (
+ lookup_type != "isnull" and internal_type in ("BinaryField", "TextField")
+ ) or (lookup_type == "exact" and internal_type == "JSONField"):
return "DBMS_LOB.SUBSTR(%s)"
return "%s"
diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py
index aa68465df9..732b30b0a4 100644
--- a/django/db/backends/postgresql/features.py
+++ b/django/db/backends/postgresql/features.py
@@ -82,6 +82,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"indexes.tests.SchemaIndexesNotPostgreSQLTests."
"test_create_index_ignores_opclasses",
},
+ "PostgreSQL requires casting to text.": {
+ "lookup.tests.LookupTests.test_textfield_exact_null",
+ },
}
@cached_property