mirror of
https://github.com/django/django.git
synced 2025-07-29 16:14:18 +00:00
Fixed #34013 -- Added QuerySet.order_by() support for annotation transforms.
Thanks Eugene Morozov and Ben Nace for the reports.
This commit is contained in:
parent
fcf95e5927
commit
b0ad41198b
6 changed files with 97 additions and 12 deletions
|
@ -469,6 +469,16 @@ class TestQuerying(PostgreSQLTestCase):
|
|||
self.assertIn("GROUP BY 2", sql)
|
||||
self.assertIn("ORDER BY 2", sql)
|
||||
|
||||
def test_order_by_arrayagg_index(self):
|
||||
qs = (
|
||||
NullableIntegerArrayModel.objects.values("order")
|
||||
.annotate(ids=ArrayAgg("id"))
|
||||
.order_by("-ids__0")
|
||||
)
|
||||
self.assertQuerySetEqual(
|
||||
qs, [{"order": obj.order, "ids": [obj.id]} for obj in reversed(self.objs)]
|
||||
)
|
||||
|
||||
def test_index(self):
|
||||
self.assertSequenceEqual(
|
||||
NullableIntegerArrayModel.objects.filter(field__0=2), self.objs[1:3]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue