From a6511bc23329f1d3939571ad01d3176f8f6cb786 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sat, 18 Feb 2023 14:53:08 +0100 Subject: [PATCH] Refs #33308 -- Added tests for queryset ordered by annotation with nulls_first/nulls_last. --- tests/ordering/tests.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py index 402e27d84b..79e1714ab6 100644 --- a/tests/ordering/tests.py +++ b/tests/ordering/tests.py @@ -165,6 +165,12 @@ class OrderingTests(TestCase): ), [self.a3, self.a4, self.a1, self.a2], ) + self.assertQuerySetEqualReversible( + Article.objects.annotate(upper_name=Upper("author__name")).order_by( + F("upper_name").asc(nulls_last=True), "headline" + ), + [self.a3, self.a4, self.a1, self.a2], + ) def test_order_by_nulls_first(self): Article.objects.filter(headline="Article 3").update(author=self.author_1) @@ -190,6 +196,12 @@ class OrderingTests(TestCase): ), [self.a1, self.a2, self.a4, self.a3], ) + self.assertQuerySetEqualReversible( + Article.objects.annotate(upper_name=Upper("author__name")).order_by( + F("upper_name").desc(nulls_first=True), "headline" + ), + [self.a1, self.a2, self.a4, self.a3], + ) def test_orders_nulls_first_on_filtered_subquery(self): Article.objects.filter(headline="Article 1").update(author=self.author_1)