1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

Fixed #7181 -- when ordering by a potentially NULL field, use a left-outer join

so that the ordering doesn't accidentally restrict the result set.

(Ironically, one existing test actually showed this problem, but I was too
dumb to notice the result was incorrect.)


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7761 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2008-06-26 06:50:22 +00:00
parent e41df5adcc
commit ba015e0a79
2 changed files with 11 additions and 1 deletions

View File

@@ -610,6 +610,10 @@ class Query(object):
alias = joins[-1]
col = target.column
# Must use left outer joins for nullable fields.
for join in joins:
self.promote_alias(join)
# If we get to this point and the field is a relation to another model,
# append the default ordering for that model.
if field.rel and len(joins) > 1 and opts.ordering: