summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 01:20:10 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 01:20:10 +0000
commit4c4341f01289e66f084d295236274a2e4556ae0d (patch)
tree9ab906748713789400f3ef555bd42717b6c037ac /tests
parente9364c06d6be32dc37e09620105e970472587d87 (diff)
queryset-refactor: Made sure the ordering columns in a distinct() query only
include the columns we are selecting on. This avoids some PostgreSQL problems and leads to more efficient queries to boot. Refs #5321. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6515 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/queries/models.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 048ced9543..9b076633c7 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -14,6 +14,7 @@ class Tag(models.Model):
class Note(models.Model):
note = models.CharField(maxlength=100)
+ misc = models.CharField(maxlength=10)
class Meta:
ordering = ['note']
@@ -91,11 +92,11 @@ __test__ = {'API_TESTS':"""
>>> t5 = Tag(name='t5', parent=t3)
>>> t5.save()
->>> n1 = Note(note='n1')
+>>> n1 = Note(note='n1', misc='foo')
>>> n1.save()
->>> n2 = Note(note='n2')
+>>> n2 = Note(note='n2', misc='bar')
>>> n2.save()
->>> n3 = Note(note='n3')
+>>> n3 = Note(note='n3', misc='foo')
>>> n3.save()
Create these out of order so that sorting by 'id' will be different to sorting
@@ -329,5 +330,9 @@ Bugs #2874, #3002
Bug #3037
>>> Item.objects.filter(Q(creator__name='a3', name='two')|Q(creator__name='a4', name='four'))
[<Item: four>]
+
+Bug #5321
+>>> Note.objects.values('misc').distinct().order_by('note', '-misc')
+[{'misc': u'foo'}, {'misc': u'bar'}]
"""}