mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #31657 -- Added test for ordering by self-referential ForeignKeys.
This commit is contained in:
committed by
Mariusz Felisiak
parent
a59de6e89e
commit
c1f7de8acc
@@ -343,6 +343,17 @@ class OrderingTests(TestCase):
|
||||
attrgetter("headline")
|
||||
)
|
||||
|
||||
def test_order_by_self_referential_fk(self):
|
||||
self.a1.author = Author.objects.create(editor=self.author_1)
|
||||
self.a1.save()
|
||||
self.a2.author = Author.objects.create(editor=self.author_2)
|
||||
self.a2.save()
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.filter(author__isnull=False).order_by('author__editor'),
|
||||
['Article 2', 'Article 1'],
|
||||
attrgetter('headline'),
|
||||
)
|
||||
|
||||
def test_order_by_f_expression(self):
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.order_by(F('headline')), [
|
||||
|
||||
Reference in New Issue
Block a user