diff options
| author | Simon Charette <charette.s@gmail.com> | 2022-11-07 09:01:50 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-11-07 09:05:24 +0100 |
| commit | 967f8750ab63f9ca74ce63ada580ccc5b10b3f3b (patch) | |
| tree | 709e63455125dce026e8a6e2c5b6dd344bd1f600 /tests/aggregation | |
| parent | 77cf70ea9699c3c4e74663955998753d70f65166 (diff) | |
Refs #27849 -- Fixed filtered aggregates crash on filters that match everything.
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 caf2cd3d6f..3ef0401d4d 100644 --- a/tests/aggregation/test_filter_argument.py +++ b/tests/aggregation/test_filter_argument.py @@ -205,3 +205,16 @@ class FilteredAggregateTests(TestCase): max_rating=Max("rating", filter=Q(rating__in=[])) ) self.assertEqual(aggregate, {"max_rating": None}) + + def test_filtered_aggregate_full_condition(self): + book = Book.objects.annotate( + authors_count=Count( + "authors", + filter=~Q(authors__in=[]), + ), + ).get(pk=self.b1.pk) + self.assertEqual(book.authors_count, 2) + aggregate = Book.objects.aggregate( + max_rating=Max("rating", filter=~Q(rating__in=[])) + ) + self.assertEqual(aggregate, {"max_rating": 4.5}) |
