diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-06-26 01:01:21 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-06-26 01:01:21 +0000 |
| commit | 183442864837386df1f24d9cd0b39a3671ef3b04 (patch) | |
| tree | 03ec7264901d5c9372dd6381d670d57a4ae1eb14 /tests | |
| parent | b8f7b39ccc414e56a99111005146b5f2d7f1d5b0 (diff) | |
Fixed a problem with values() and values_list() queries and nullable joins.
Previously, if we were querying across a nullable join and then a non-nullable
one, the second join would not be a LEFT OUTER join, which would exclude
certain valid results from the result set.
This is the same problem as [7597] but for values() field specifications, so
this covers the second case where Django adds extra stuff to the select-clause.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7740 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/queries/models.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py index 7270c21dac..5af48741d6 100644 --- a/tests/regressiontests/queries/models.py +++ b/tests/regressiontests/queries/models.py @@ -58,7 +58,7 @@ class Item(models.Model): class Report(models.Model): name = models.CharField(max_length=10) - creator = models.ForeignKey(Author, to_field='num') + creator = models.ForeignKey(Author, to_field='num', null=True) def __unicode__(self): return self.name @@ -191,6 +191,8 @@ by 'info'. Helps detect some problems later. >>> r1.save() >>> r2 = Report(name='r2', creator=a3) >>> r2.save() +>>> r3 = Report(name='r3') +>>> r3.save() Ordering by 'rank' gives us rank2, rank1, rank3. Ordering by the Meta.ordering will be rank3, rank2, rank1. @@ -713,5 +715,10 @@ in MySQL. This exercises that case. >>> mm = ManagedModel.objects.create(data='mm1', tag=t1, is_public=True) >>> ManagedModel.objects.update(data='mm') +A values() or values_list() query across joined models must use outer joins +appropriately. +>>> Report.objects.values_list("creator__extra__info", flat=True).order_by("name") +[u'e1', u'e2', None] + """} |
