1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #34975 -- Complemented rhs filtering aggregations for __in lookup.

While this isn't a regression it's clear that similar logic should be
applied when dealing with lists of expressions passed as a lookup value.
This commit is contained in:
Simon Charette
2023-11-17 20:40:31 -05:00
committed by Mariusz Felisiak
parent 7530cf3900
commit 15cb3c262a
3 changed files with 15 additions and 1 deletions

View File

@@ -2315,3 +2315,9 @@ class AggregateAnnotationPruningTests(TestCase):
max_book_author=Max("book__authors"),
).aggregate(count=Count("id", filter=Q(id=F("max_book_author"))))
self.assertEqual(aggregates, {"count": 1})
def test_aggregate_reference_lookup_rhs_iter(self):
aggregates = Author.objects.annotate(
max_book_author=Max("book__authors"),
).aggregate(count=Count("id", filter=Q(id__in=[F("max_book_author"), 0])))
self.assertEqual(aggregates, {"count": 1})