diff options
| author | Simon Charette <charette.s@gmail.com> | 2025-01-07 00:02:31 -0500 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-08 10:20:48 +0100 |
| commit | 42e8f264ce55710056b0033682ec6fd662a25b29 (patch) | |
| tree | 19fb128be8a41b2bba9b3a36a09b48bdb75dd346 /tests/composite_pk | |
| parent | 7617d5be94a6e348d5ddf4644985b24235822034 (diff) | |
Fixed #36065 -- Fixed ordering by expression referencing composite primary key.
Thanks Jacob Walls for the report and test and Csirmaz Bendegúz for the review.
Diffstat (limited to 'tests/composite_pk')
| -rw-r--r-- | tests/composite_pk/test_order_by.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/composite_pk/test_order_by.py b/tests/composite_pk/test_order_by.py index 9d3dec58e7..f17d6b55e4 100644 --- a/tests/composite_pk/test_order_by.py +++ b/tests/composite_pk/test_order_by.py @@ -1,3 +1,4 @@ +from django.db.models import F from django.test import TestCase from .models import Comment, Tenant, User @@ -55,3 +56,17 @@ class CompositePKOrderByTests(TestCase): self.comment_1, # (1, 1) ), ) + + def test_order_comments_by_pk_expr(self): + self.assertQuerySetEqual( + Comment.objects.order_by("pk"), + Comment.objects.order_by(F("pk")), + ) + self.assertQuerySetEqual( + Comment.objects.order_by("-pk"), + Comment.objects.order_by(F("pk").desc()), + ) + self.assertQuerySetEqual( + Comment.objects.order_by("-pk"), + Comment.objects.order_by(F("pk").desc(nulls_last=True)), + ) |
