From 08b4dfc5734f5d2fce685eabcd65385a6656db2f Mon Sep 17 00:00:00 2001 From: VIZZARD-X Date: Sat, 10 Jan 2026 02:26:37 +0530 Subject: Fixed #36857 -- Added QuerySet.totally_ordered property. Thanks Simon Charette for the idea. --- tests/ordering/models.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/ordering/models.py') diff --git a/tests/ordering/models.py b/tests/ordering/models.py index c365da7642..a4e4b82d40 100644 --- a/tests/ordering/models.py +++ b/tests/ordering/models.py @@ -59,6 +59,7 @@ class ChildArticle(Article): class Reference(models.Model): article = models.ForeignKey(OrderedByAuthorArticle, models.CASCADE) + proof = models.OneToOneField(Article, models.CASCADE, related_name="+") class Meta: ordering = ("article",) @@ -80,3 +81,31 @@ class OrderedByExpressionChild(models.Model): class OrderedByExpressionGrandChild(models.Model): parent = models.ForeignKey(OrderedByExpressionChild, models.CASCADE) + + +class BarcodedArticle(models.Model): + rank = models.IntegerField(unique=True, null=True) + headline = models.CharField(max_length=100) + slug = models.CharField(max_length=100, default="slug") + pub_date = models.DateField(null=True) + barcode = models.CharField(max_length=30, default="bar") + + class Meta: + required_db_features = {"supports_partial_indexes"} + unique_together = (("headline", "slug"),) + constraints = [ + models.UniqueConstraint( + fields=["pub_date", "rank"], + name="unique_pub_date_rank", + ), + models.UniqueConstraint( + fields=["rank"], + condition=models.Q(rank__gt=0), + name="unique_rank_conditional", + ), + models.UniqueConstraint( + fields=["barcode"], + condition=models.Q(), + name="unique_barcode_empty_condition", + ), + ] -- cgit v1.3