mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
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 e5a92d400a.
Thanks Fernando Flores Villaça for the report.
This commit is contained in:
committed by
Mariusz Felisiak
parent
a2e580acf6
commit
32536b1324
@@ -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