mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[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 ine5a92d400a. Thanks Fernando Flores Villaça for the report. Backport of32536b1324from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
7ba9a44831
commit
e0f14d8389
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user