mirror of
https://github.com/django/django.git
synced 2025-11-28 22:49:09 +00:00
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:
parent
f5dccbafb9
commit
f42ccdd835
11 changed files with 268 additions and 48 deletions
|
|
@ -1262,9 +1262,9 @@ class Query(BaseExpression):
|
|||
if hasattr(filter_expr, 'resolve_expression'):
|
||||
if not getattr(filter_expr, 'conditional', False):
|
||||
raise TypeError('Cannot filter against a non-conditional expression.')
|
||||
condition = self.build_lookup(
|
||||
['exact'], filter_expr.resolve_expression(self, allow_joins=allow_joins), True
|
||||
)
|
||||
condition = filter_expr.resolve_expression(self, allow_joins=allow_joins)
|
||||
if not isinstance(condition, Lookup):
|
||||
condition = self.build_lookup(['exact'], condition, True)
|
||||
clause = self.where_class()
|
||||
clause.add(condition, AND)
|
||||
return clause, []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue