From 200cd8803d51e94a0724f9fcd3782e71752ef424 Mon Sep 17 00:00:00 2001 From: Baptiste Mispelon Date: Wed, 11 Dec 2019 15:25:50 +0100 Subject: [PATCH] Refs #25361 -- Added test for pickling queryset of abstract-inherited models with Meta.ordering. Fixed in 67cf5efa31acb2916034afb15610b700695dfcb0. --- tests/queryset_pickle/models.py | 14 ++++++++++++++ tests/queryset_pickle/tests.py | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/queryset_pickle/models.py b/tests/queryset_pickle/models.py index 1275ed6f20..23237a3ec2 100644 --- a/tests/queryset_pickle/models.py +++ b/tests/queryset_pickle/models.py @@ -58,3 +58,17 @@ class Container: class M2MModel(models.Model): groups = models.ManyToManyField(Group) + + +class AbstractEvent(Event): + class Meta: + abstract = True + ordering = ['title'] + + +class MyEvent(AbstractEvent): + pass + + +class Edition(models.Model): + event = models.ForeignKey('MyEvent', on_delete=models.CASCADE) diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index 9ef19cfa9d..793141cfdd 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -5,7 +5,7 @@ from django.db import models from django.test import TestCase from django.utils.version import get_version -from .models import Container, Event, Group, Happening, M2MModel +from .models import Container, Event, Group, Happening, M2MModel, MyEvent class PickleabilityTestCase(TestCase): @@ -238,6 +238,12 @@ class PickleabilityTestCase(TestCase): with self.assertRaisesMessage(RuntimeWarning, msg): pickle.loads(pickle.dumps(qs)) + def test_order_by_model_with_abstract_inheritance_and_meta_ordering(self): + group = Group.objects.create(name='test') + event = MyEvent.objects.create(title='test event', group=group) + event.edition_set.create() + self.assert_pickles(event.edition_set.order_by('event')) + class InLookupTests(TestCase):