mirror of
https://github.com/django/django.git
synced 2025-08-30 23:37:50 +00:00
Fixed #31377 -- Disabled grouping by aliases on QuerySet.values()/values_list() when they collide with field names.
Regression in fb3f034f1c
.
Thanks Holovashchenko Vadym for the report.
This commit is contained in:
parent
895f28f9cb
commit
10866a10fe
4 changed files with 35 additions and 1 deletions
|
@ -1191,6 +1191,22 @@ class AggregateTestCase(TestCase):
|
|||
},
|
||||
])
|
||||
|
||||
def test_aggregation_subquery_annotation_values_collision(self):
|
||||
books_rating_qs = Book.objects.filter(
|
||||
publisher=OuterRef('pk'),
|
||||
price=Decimal('29.69'),
|
||||
).values('rating')
|
||||
publisher_qs = Publisher.objects.filter(
|
||||
book__contact__age__gt=20,
|
||||
name=self.p1.name,
|
||||
).annotate(
|
||||
rating=Subquery(books_rating_qs),
|
||||
contacts_count=Count('book__contact'),
|
||||
).values('rating').annotate(total_count=Count('rating'))
|
||||
self.assertEqual(list(publisher_qs), [
|
||||
{'rating': 4.0, 'total_count': 2},
|
||||
])
|
||||
|
||||
@skipUnlessDBFeature('supports_subqueries_in_group_by')
|
||||
@skipIf(
|
||||
connection.vendor == 'mysql' and 'ONLY_FULL_GROUP_BY' in connection.sql_mode,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue