Fixed #27021 -- Allowed lookup expressions in annotations, aggregations, and QuerySet.filter().

Thanks Hannes Ljungberg and Simon Charette for reviews.

Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
This commit is contained in:
Ian Foote 2021-04-02 18:25:20 +01:00 committed by Mariusz Felisiak
parent f5dccbafb9
commit f42ccdd835
11 changed files with 268 additions and 48 deletions

View file

@ -1248,9 +1248,9 @@ class OrderBy(Expression):
return (template % placeholders).rstrip(), params
def as_oracle(self, compiler, connection):
# Oracle doesn't allow ORDER BY EXISTS() unless it's wrapped in
# a CASE WHEN.
if isinstance(self.expression, Exists):
# Oracle doesn't allow ORDER BY EXISTS() or filters unless it's wrapped
# in a CASE WHEN.
if connection.ops.conditional_expression_supported_in_where_clause(self.expression):
copy = self.copy()
copy.expression = Case(
When(self.expression, then=True),