Removed serial pk assumption in ordering tests.
Fixed OrderingTests.test_order_by_fk_attname and test_order_by_pk on CockroachDB.
This commit is contained in:
parent
009fddc96b
commit
be27da9d6e
|
@ -315,10 +315,9 @@ class OrderingTests(TestCase):
|
||||||
"""
|
"""
|
||||||
'pk' works as an ordering option in Meta.
|
'pk' works as an ordering option in Meta.
|
||||||
"""
|
"""
|
||||||
self.assertQuerysetEqual(
|
self.assertEqual(
|
||||||
Author.objects.all(),
|
[a.pk for a in Author.objects.all()],
|
||||||
list(reversed(range(1, Author.objects.count() + 1))),
|
[a.pk for a in Author.objects.order_by('-pk')],
|
||||||
attrgetter("pk"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_order_by_fk_attname(self):
|
def test_order_by_fk_attname(self):
|
||||||
|
@ -326,8 +325,9 @@ class OrderingTests(TestCase):
|
||||||
ordering by a foreign key by its attribute name prevents the query
|
ordering by a foreign key by its attribute name prevents the query
|
||||||
from inheriting its related model ordering option (#19195).
|
from inheriting its related model ordering option (#19195).
|
||||||
"""
|
"""
|
||||||
|
authors = list(Author.objects.order_by('id'))
|
||||||
for i in range(1, 5):
|
for i in range(1, 5):
|
||||||
author = Author.objects.get(pk=i)
|
author = authors[i - 1]
|
||||||
article = getattr(self, "a%d" % (5 - i))
|
article = getattr(self, "a%d" % (5 - i))
|
||||||
article.author = author
|
article.author = author
|
||||||
article.save(update_fields={'author'})
|
article.save(update_fields={'author'})
|
||||||
|
|
Loading…
Reference in New Issue