mirror of
https://github.com/django/django.git
synced 2025-07-28 15:44:20 +00:00
Refs #28900 -- Made SELECT respect the order specified by values(*selected).
Previously the order was always extra_fields + model_fields + annotations with
respective local ordering inferred from the insertion order of *selected.
This commits introduces a new `Query.selected` propery that keeps tracks of the
global select order as specified by on values assignment. This is crucial
feature to allow the combination of queries mixing annotations and table
references.
It also allows the removal of the re-ordering shenanigans perform by
ValuesListIterable in order to re-map the tuples returned from the database
backend to the order specified by values_list() as they'll be in the right
order at query compilation time.
Refs #28553 as the initially reported issue that was only partially fixed
for annotations by d6b6e5d0fd
.
Thanks Mariusz Felisiak and Sarah Boyce for review.
This commit is contained in:
parent
2e47dde438
commit
65ad4ade74
10 changed files with 125 additions and 62 deletions
|
@ -466,8 +466,8 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
],
|
||||
)
|
||||
sql = ctx[0]["sql"]
|
||||
self.assertIn("GROUP BY 2", sql)
|
||||
self.assertIn("ORDER BY 2", sql)
|
||||
self.assertIn("GROUP BY 1", sql)
|
||||
self.assertIn("ORDER BY 1", sql)
|
||||
|
||||
def test_order_by_arrayagg_index(self):
|
||||
qs = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue