mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #34012 -- Added test for ordering by transform of related fields.
This commit is contained in:
parent
ce6230aa97
commit
37a13cc92d
@ -392,6 +392,20 @@ class Queries1Tests(TestCase):
|
||||
qs = qs.order_by("id")
|
||||
self.assertNotIn("OUTER JOIN", str(qs.query))
|
||||
|
||||
def test_order_by_related_field_transform(self):
|
||||
extra_12 = ExtraInfo.objects.create(
|
||||
info="extra 12",
|
||||
date=DateTimePK.objects.create(date=datetime.datetime(2021, 12, 10)),
|
||||
)
|
||||
extra_11 = ExtraInfo.objects.create(
|
||||
info="extra 11",
|
||||
date=DateTimePK.objects.create(date=datetime.datetime(2022, 11, 10)),
|
||||
)
|
||||
self.assertSequenceEqual(
|
||||
ExtraInfo.objects.filter(date__isnull=False).order_by("date__month"),
|
||||
[extra_11, extra_12],
|
||||
)
|
||||
|
||||
def test_filter_by_related_field_transform(self):
|
||||
extra_old = ExtraInfo.objects.create(
|
||||
info="extra 12",
|
||||
|
Loading…
Reference in New Issue
Block a user