Fixed #34346 -- Ordered selected expressions by position.

Used the same approach as for #34176 by using selected expressions
position to prevent ambiguous aliases in collisions.

Thanks henribru for the report.

Regression in 04518e310d.
This commit is contained in:
Simon Charette 2023-02-17 20:38:08 -05:00 committed by Mariusz Felisiak
parent f91e085c30
commit 278881e376
3 changed files with 55 additions and 10 deletions

View file

@ -465,10 +465,9 @@ class TestQuerying(PostgreSQLTestCase):
{"field__0": 20, "arrayagg": [self.objs[3].pk]},
],
)
alias = connection.ops.quote_name("field__0")
sql = ctx[0]["sql"]
self.assertIn("GROUP BY 1", sql)
self.assertIn(f"ORDER BY {alias}", sql)
self.assertIn("ORDER BY 1", sql)
def test_index(self):
self.assertSequenceEqual(