diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/many_to_one/models.py | 4 | ||||
| -rw-r--r-- | tests/regressiontests/queries/models.py | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py index d2c8e87fc1..6616f8b55e 100644 --- a/tests/modeltests/many_to_one/models.py +++ b/tests/modeltests/many_to_one/models.py @@ -250,9 +250,9 @@ FieldError: Cannot resolve keyword 'reporter_id' into field. Choices are: headli >>> Reporter.objects.filter(article__reporter=r).distinct() [<Reporter: John Smith>] -# It's possible to use values() calls across many-to-one relations. +# It's possible to use values() calls across many-to-one relations. (Note, too, that we clear the ordering here so as not to drag the 'headline' field into the columns being used to determine uniqueness.) >>> d = {'reporter__first_name': u'John', 'reporter__last_name': u'Smith'} ->>> list(Article.objects.filter(reporter=r).distinct().values('reporter__first_name', 'reporter__last_name')) == [d] +>>> list(Article.objects.filter(reporter=r).distinct().order_by().values('reporter__first_name', 'reporter__last_name')) == [d] True # If you delete a reporter, his articles will be deleted. diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index d99e828c3b..f893ac6ad8 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -498,9 +498,15 @@ Bug #3037 >>> Item.objects.filter(Q(creator__name='a3', name='two')|Q(creator__name='a4', name='four')) [<Item: four>] -Bug #5321 +Bug #5321, #7070 + +Ordering columns must be included in the output columns. Note that this means +results that might otherwise be distinct are not (if there are multiple values +in the ordering cols), as in this example. This isn't a bug; it's a warning to +be careful with the selection of ordering columns. + >>> Note.objects.values('misc').distinct().order_by('note', '-misc') -[{'misc': u'foo'}, {'misc': u'bar'}] +[{'misc': u'foo'}, {'misc': u'bar'}, {'misc': u'foo'}] Bug #4358 If you don't pass any fields to values(), relation fields are returned as |
