1
0
mirror of https://github.com/django/django.git synced 2024-12-22 17:16:24 +00:00

Refs #27849 -- Added test for filtered aggregates with empty conditions.

This commit is contained in:
Simon Charette 2022-11-07 08:57:40 +01:00 committed by Mariusz Felisiak
parent 123b1d3fcf
commit 77cf70ea96

View File

@ -192,3 +192,16 @@ class FilteredAggregateTests(TestCase):
), ),
) )
self.assertEqual(aggregate, {"max_rating": 4.5}) self.assertEqual(aggregate, {"max_rating": 4.5})
def test_filtered_aggregate_empty_condition(self):
book = Book.objects.annotate(
authors_count=Count(
"authors",
filter=Q(authors__in=[]),
),
).get(pk=self.b1.pk)
self.assertEqual(book.authors_count, 0)
aggregate = Book.objects.aggregate(
max_rating=Max("rating", filter=Q(rating__in=[]))
)
self.assertEqual(aggregate, {"max_rating": None})