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 05:50:02 +0200 |
| commit | 32536b1324e98768dd892980408a8c6b26c23fd9 (patch) | |
| tree | 2aacd612afe69bd4ed413b82d1e065ad21e230c8 /tests/aggregation | |
| parent | a2e580acf62a3de4f9108cc1af061a02b94b1064 (diff) | |
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.
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 75a4e0d022..5ec12ccd64 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. |
