mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #24654 -- Based ordering circular references detection on columns.
Thanks to Elmar Bucher for the report and Tim for the review.
This commit is contained in:
parent
ffe83d16bd
commit
b44ed404c7
3 changed files with 33 additions and 2 deletions
|
@ -6,7 +6,7 @@ from operator import attrgetter
|
|||
from django.db.models import F
|
||||
from django.test import TestCase
|
||||
|
||||
from .models import Article, Author
|
||||
from .models import Article, Author, Reference
|
||||
|
||||
|
||||
class OrderingTests(TestCase):
|
||||
|
@ -307,3 +307,20 @@ class OrderingTests(TestCase):
|
|||
],
|
||||
attrgetter("headline")
|
||||
)
|
||||
|
||||
def test_related_ordering_duplicate_table_reference(self):
|
||||
"""
|
||||
An ordering referencing a model with an ordering referencing a model
|
||||
multiple time no circular reference should be detected (#24654).
|
||||
"""
|
||||
first_author = Author.objects.create()
|
||||
second_author = Author.objects.create()
|
||||
self.a1.author = first_author
|
||||
self.a1.second_author = second_author
|
||||
self.a1.save()
|
||||
self.a2.author = second_author
|
||||
self.a2.second_author = first_author
|
||||
self.a2.save()
|
||||
r1 = Reference.objects.create(article_id=self.a1.pk)
|
||||
r2 = Reference.objects.create(article_id=self.a2.pk)
|
||||
self.assertQuerysetEqual(Reference.objects.all(), [r2, r1], lambda x: x)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue