mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #34176 -- Fixed grouping by ambiguous aliases.
Regression inb7b28c7c18. Refs #31377. Thanks Shai Berger for the report and reviews. test_aggregation_subquery_annotation_values_collision() has been updated as queries that are explicitly grouped by a subquery should always be grouped by it and not its outer columns even if its alias collides with referenced table columns. This was not possible to accomplish at the time10866a10landed because we didn't have compiler level handling of colliding aliases.
This commit is contained in:
committed by
Mariusz Felisiak
parent
016bead6a2
commit
dd68af62b2
@@ -449,8 +449,8 @@ class TestQuerying(PostgreSQLTestCase):
|
||||
expected,
|
||||
)
|
||||
|
||||
@skipUnlessDBFeature("allows_group_by_refs")
|
||||
def test_group_by_order_by_aliases(self):
|
||||
@skipUnlessDBFeature("allows_group_by_select_index")
|
||||
def test_group_by_order_by_select_index(self):
|
||||
with self.assertNumQueries(1) as ctx:
|
||||
self.assertSequenceEqual(
|
||||
NullableIntegerArrayModel.objects.filter(
|
||||
@@ -467,7 +467,7 @@ class TestQuerying(PostgreSQLTestCase):
|
||||
)
|
||||
alias = connection.ops.quote_name("field__0")
|
||||
sql = ctx[0]["sql"]
|
||||
self.assertIn(f"GROUP BY {alias}", sql)
|
||||
self.assertIn("GROUP BY 1", sql)
|
||||
self.assertIn(f"ORDER BY {alias}", sql)
|
||||
|
||||
def test_index(self):
|
||||
|
||||
Reference in New Issue
Block a user