Refs #32673 -- Fixed lookups crash when comparing against lookups on Oracle.

Follow up to 170b006ce8.
This commit is contained in:
Mariusz Felisiak 2021-04-23 16:32:53 +02:00 committed by GitHub
parent 170b006ce8
commit 0aacbdcf27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -87,10 +87,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
'Raises ORA-00600: internal error code.': {
'model_fields.test_jsonfield.TestQuerying.test_usage_in_subquery',
},
"Oracle doesn't allow filters to be compared to another expression in "
"the WHERE clause.": {
'lookup.tests.LookupTests.test_lookup_rhs',
},
}
django_test_expected_failures = {
# A bug in Django/cx_Oracle with respect to string handling (#23843).

View File

@ -3,7 +3,7 @@ import math
from copy import copy
from django.core.exceptions import EmptyResultSet
from django.db.models.expressions import Case, Exists, Func, Value, When
from django.db.models.expressions import Case, Func, Value, When
from django.db.models.fields import (
CharField, DateTimeField, Field, IntegerField, UUIDField,
)
@ -124,12 +124,12 @@ class Lookup:
raise NotImplementedError
def as_oracle(self, compiler, connection):
# Oracle doesn't allow EXISTS() to be compared to another expression
# unless it's wrapped in a CASE WHEN.
# Oracle doesn't allow EXISTS() and filters to be compared to another
# expression unless they're wrapped in a CASE WHEN.
wrapped = False
exprs = []
for expr in (self.lhs, self.rhs):
if isinstance(expr, Exists):
if connection.ops.conditional_expression_supported_in_where_clause(expr):
expr = Case(When(expr, then=True), default=False)
wrapped = True
exprs.append(expr)