mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #31285 -- Fixed inherited Meta.ordering of "-pk".
This commit is contained in:
committed by
Mariusz Felisiak
parent
142ab6846a
commit
013147fae2
@@ -7,7 +7,7 @@ from django.test.utils import CaptureQueriesContext, isolate_apps
|
||||
|
||||
from .models import (
|
||||
Base, Chef, CommonInfo, GrandChild, GrandParent, ItalianRestaurant,
|
||||
MixinModel, ParkingLot, Place, Post, Restaurant, Student, SubBase,
|
||||
MixinModel, Parent, ParkingLot, Place, Post, Restaurant, Student, SubBase,
|
||||
Supplier, Title, Worker,
|
||||
)
|
||||
|
||||
@@ -204,6 +204,19 @@ class ModelInheritanceTests(TestCase):
|
||||
|
||||
self.assertEqual(A.attr.called, (A, 'attr'))
|
||||
|
||||
def test_inherited_ordering_pk_desc(self):
|
||||
p1 = Parent.objects.create(first_name='Joe', email='joe@email.com')
|
||||
p2 = Parent.objects.create(first_name='Jon', email='jon@email.com')
|
||||
expected_order_by_sql = 'ORDER BY %s.%s DESC' % (
|
||||
connection.ops.quote_name(Parent._meta.db_table),
|
||||
connection.ops.quote_name(
|
||||
Parent._meta.get_field('grandparent_ptr').column
|
||||
),
|
||||
)
|
||||
qs = Parent.objects.all()
|
||||
self.assertSequenceEqual(qs, [p2, p1])
|
||||
self.assertIn(expected_order_by_sql, str(qs.query))
|
||||
|
||||
|
||||
class ModelInheritanceDataTests(TestCase):
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user