mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #31109 -- Disabled grouping by aliases on QuerySet.exists().
Clearing the SELECT clause in Query.has_results was orphaning GROUP BY
references to it.
Thanks Thierry Bastian for the report and Baptiste Mispelon for the
bisect.
Regression in fb3f034f1c.
This commit is contained in:
committed by
Mariusz Felisiak
parent
cebd41e416
commit
720de4d044
@@ -1141,6 +1141,16 @@ class AggregateTestCase(TestCase):
|
||||
# The GROUP BY should not be by alias either.
|
||||
self.assertEqual(ctx[0]['sql'].lower().count('latest_book_pubdate'), 1)
|
||||
|
||||
def test_aggregation_subquery_annotation_exists(self):
|
||||
latest_book_pubdate_qs = Book.objects.filter(
|
||||
publisher=OuterRef('pk')
|
||||
).order_by('-pubdate').values('pubdate')[:1]
|
||||
publisher_qs = Publisher.objects.annotate(
|
||||
latest_book_pubdate=Subquery(latest_book_pubdate_qs),
|
||||
count=Count('book'),
|
||||
)
|
||||
self.assertTrue(publisher_qs.exists())
|
||||
|
||||
@skipUnlessDBFeature('supports_subqueries_in_group_by')
|
||||
def test_group_by_subquery_annotation(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user