From 415ffa8df56d72bf6f114abc8fdae11d459e768d Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 28 Feb 2009 02:59:40 +0000 Subject: 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 --- django/db/models/sql/query.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'django/db/models/sql/query.py') diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index af9d173f4c..ac100c06e5 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -716,7 +716,7 @@ class BaseQuery(object): result, params = [], [] if self.group_by is not None: group_by = self.group_by or [] - + extra_selects = [] for extra_select, extra_params in self.extra_select.itervalues(): extra_selects.append(extra_select) @@ -834,8 +834,9 @@ class BaseQuery(object): # the model. self.ref_alias(alias) - # Must use left outer joins for nullable fields. - self.promote_alias_chain(joins) + # Must use left outer joins for nullable fields and their relations. + self.promote_alias_chain(joins, + self.alias_map[joins[0]][JOIN_TYPE] == self.LOUTER) # If we get to this point and the field is a relation to another model, # append the default ordering for that model. -- cgit v1.3