summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-02-28 02:59:40 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-02-28 02:59:40 +0000
commit415ffa8df56d72bf6f114abc8fdae11d459e768d (patch)
tree905870251d3f8c77cc64825df0e59726732f9601 /tests
parent4ad77254b4ca5a2c7e6663d5a77c26b6802886f4 (diff)
Fixed #10028 -- Fixed a problem when ordering by related models.
Some results were inadvertently being excluded if we were ordering across a nullable relation which itself ordering by a non-nullable relation. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9916 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/queries/models.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index e8cf645633..a4182c6c90 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -238,6 +238,32 @@ class PointerA(models.Model):
class PointerB(models.Model):
connection = models.ForeignKey(SharedConnection)
+# Multi-layer ordering
+class SingleObject(models.Model):
+ name = models.CharField(max_length=10)
+
+ class Meta:
+ ordering = ['name']
+
+ def __unicode__(self):
+ return self.name
+
+class RelatedObject(models.Model):
+ single = models.ForeignKey(SingleObject)
+
+ class Meta:
+ ordering = ['single']
+
+class Plaything(models.Model):
+ name = models.CharField(max_length=10)
+ others = models.ForeignKey(RelatedObject, null=True)
+
+ class Meta:
+ ordering = ['others']
+
+ def __unicode__(self):
+ return self.name
+
__test__ = {'API_TESTS':"""
>>> t1 = Tag.objects.create(name='t1')
@@ -1044,6 +1070,11 @@ Bug #9985 -- qs.values_list(...).values(...) combinations should work.
>>> Annotation.objects.filter(notes__in=Note.objects.filter(note="n1").values_list('note').values('id'))
[<Annotation: a1>]
+Bug #10028 -- ordering by model related to nullable relations(!) should use
+outer joins, so that all results are included.
+>>> _ = Plaything.objects.create(name="p1")
+>>> Plaything.objects.all()
+[<Plaything: p1>]
"""}
# In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__