mirror of
https://github.com/django/django.git
synced 2025-10-26 07:06:08 +00:00
[4.2.x] Fixed #34748 -- Fixed queryset crash when grouping by a reference in a subquery.
Regression indd68af62b2. Thanks Toan Vuong for the report. Backport of4087367ba8from main
This commit is contained in:
committed by
Mariusz Felisiak
parent
a52a2b6678
commit
739da73164
@@ -2116,6 +2116,16 @@ class AggregateTestCase(TestCase):
|
||||
},
|
||||
)
|
||||
|
||||
def test_group_by_reference_subquery(self):
|
||||
author_qs = (
|
||||
Author.objects.annotate(publisher_id=F("book__publisher"))
|
||||
.values("publisher_id")
|
||||
.annotate(cnt=Count("*"))
|
||||
.values("publisher_id")
|
||||
)
|
||||
qs = Publisher.objects.filter(pk__in=author_qs)
|
||||
self.assertCountEqual(qs, [self.p1, self.p2, self.p3, self.p4])
|
||||
|
||||
|
||||
class AggregateAnnotationPruningTests(TestCase):
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user