diff options
| author | Simon Charette <charette.s@gmail.com> | 2022-11-07 08:57:40 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-11-07 08:57:40 +0100 |
| commit | 77cf70ea9699c3c4e74663955998753d70f65166 (patch) | |
| tree | 744535fccd2b1ee39ea862383ab0f1c01189c514 /tests/aggregation | |
| parent | 123b1d3fcf79f091573c40be6da7113a6ef35b62 (diff) | |
Refs #27849 -- Added test for filtered aggregates with empty conditions.
Diffstat (limited to 'tests/aggregation')
| -rw-r--r-- | tests/aggregation/test_filter_argument.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/aggregation/test_filter_argument.py b/tests/aggregation/test_filter_argument.py index f55e06dfa0..caf2cd3d6f 100644 --- a/tests/aggregation/test_filter_argument.py +++ b/tests/aggregation/test_filter_argument.py @@ -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}) |
