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:
parent
123b1d3fcf
commit
77cf70ea96
@ -192,3 +192,16 @@ class FilteredAggregateTests(TestCase):
|
||||
),
|
||||
)
|
||||
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})
|
||||
|
Loading…
Reference in New Issue
Block a user