summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2023-02-27 01:10:19 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-27 07:10:45 +0100
commit872dade29c8a4b9e82920a85c698fcef8ed332ee (patch)
treebad75170eb159805c661e32d1a504be6c4748b82 /tests
parent5a82acbda8c9a7b83030101024def2404318dca9 (diff)
[4.2.x] Fixed #34372 -- Fixed queryset crash on order by aggregation using OrderBy.
Regression in 278881e37619278789942513916acafaa88d26f3 caused by a lack of expression copying when an OrderBy expression is explicitly provided. Thanks Jannis Vajen for the report and regression test. Backport of b15f162f252610e3b510ade465549769ab4356cf from main
Diffstat (limited to 'tests')
-rw-r--r--tests/ordering/tests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py
index 7ff38acc4a..b29404ed77 100644
--- a/tests/ordering/tests.py
+++ b/tests/ordering/tests.py
@@ -638,3 +638,9 @@ class OrderingTests(TestCase):
.first(),
self.a1,
)
+
+ def test_order_by_expr_query_reuse(self):
+ qs = Author.objects.annotate(num=Count("article")).order_by(
+ F("num").desc(), "pk"
+ )
+ self.assertCountEqual(qs, qs.iterator())