Ticket #30557: 30557.diff

File 30557.diff, 1.9 KB (added by Mariusz Felisiak, 5 years ago)

Regression test.

  • tests/model_inheritance/models.py

    diff --git a/tests/model_inheritance/models.py b/tests/model_inheritance/models.py
    index a4f9cfe696..f3f1b4a357 100644
    a b class Place(models.Model):  
    9191    def __str__(self):
    9292        return "%s the place" % self.name
    9393
     94    class Meta:
     95        ordering = [models.F('name').desc(nulls_last=True)]
     96
    9497
    9598class Rating(models.Model):
    9699    rating = models.IntegerField(null=True, blank=True)
  • tests/ordering/models.py

    diff --git a/tests/ordering/models.py b/tests/ordering/models.py
    index 8b71983c44..b8b11de86f 100644
    a b class Reference(models.Model):  
    5959
    6060    class Meta:
    6161        ordering = ('article',)
     62
     63
     64class SubArticle(Article):
     65    pass
  • tests/ordering/tests.py

    diff --git a/tests/ordering/tests.py b/tests/ordering/tests.py
    index 18c32d6d5f..39b5a75564 100644
    a b from django.db.models.functions import Upper  
    99from django.test import TestCase
    1010from django.utils.deprecation import RemovedInDjango31Warning
    1111
    12 from .models import Article, Author, OrderedByFArticle, Reference
     12from .models import Article, Author, OrderedByFArticle, Reference, SubArticle
    1313
    1414
    1515class OrderingTests(TestCase):
    class OrderingTests(TestCase):  
    462462            attrgetter('headline')
    463463        )
    464464
     465    def test_default_parent_ordering_by_expression(self):
     466        sub1 = SubArticle.objects.create(headline='Sub 1', pub_date=datetime(2005, 7, 26))
     467        sub2 = SubArticle.objects.create(headline='Sub 2', pub_date=datetime(2005, 7, 27))
     468        articles = SubArticle.objects.order_by('article_ptr')
     469        self.assertSequenceEqual(articles, [sub2, sub1])
     470
    465471    def test_deprecated_values_annotate(self):
    466472        msg = (
    467473            "Article QuerySet won't use Meta.ordering in Django 3.1. Add "
Back to Top