diff options
| author | Simon Charette <charette.s@gmail.com> | 2022-09-07 22:30:06 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-09-08 08:13:15 +0200 |
| commit | e0f14d83898ee7d0d3180eb96214d8fcdf82cc1d (patch) | |
| tree | f481573347c651c013db1cd53a347efabcc5f8aa /tests/aggregation | |
| parent | 7ba9a448316de976735c1b14d069ed033ebed6ea (diff) | |
[4.1.x] Fixed #33992 -- Fixed queryset crash when aggregating over a group containing Exists.
A more in-depth solution is likely to make sure that we always GROUP BY
selected annotations or revisit how we use Query.exists() in the Exists
expression but that requires extra work that isn't suitable for a
backport.
Regression in e5a92d400acb4ca6a8e1375d1ab8121f2c7220be.
Thanks Fernando Flores Villaça for the report.
Backport of 32536b1324e98768dd892980408a8c6b26c23fd9 from main
Diffstat (limited to 'tests/aggregation')
| -rw-r--r-- | tests/aggregation/tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index c6d73e8042..bbd4620710 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -1663,6 +1663,17 @@ class AggregateTestCase(TestCase): ).values_list("publisher_count", flat=True) self.assertSequenceEqual(books_breakdown, [1] * 6) + def test_aggregation_exists_multivalued_outeref(self): + self.assertCountEqual( + Publisher.objects.annotate( + books_exists=Exists( + Book.objects.filter(publisher=OuterRef("book__publisher")) + ), + books_count=Count("book"), + ), + Publisher.objects.all(), + ) + def test_filter_in_subquery_or_aggregation(self): """ Filtering against an aggregate requires the usage of the HAVING clause. |
