summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorJustin Bronn <jbronn@gmail.com>2008-06-16 00:34:17 +0000
committerJustin Bronn <jbronn@gmail.com>2008-06-16 00:34:17 +0000
commit842dae0ed59cc7566cf35090093222ea3a61ec79 (patch)
tree9602bc18a8d3a7da81b2009ba8e7d51276bd1841 /django/db/models/sql/query.py
parent4ec80c4333b618fc1ef2a02c7b8ca8719792f25f (diff)
gis: Merged revisions 7574-7583,7585-7586,7590-7602,7614-7615,7619-7625,7629,7632-7636 via svnmerge from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@7642 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index a6957bab7b..3044882a86 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -851,7 +851,7 @@ class Query(object):
return alias
def fill_related_selections(self, opts=None, root_alias=None, cur_depth=1,
- used=None, requested=None, restricted=None):
+ used=None, requested=None, restricted=None, nullable=None):
"""
Fill in the information needed for a select_related query. The current
depth is measured as the number of connections away from the root model
@@ -883,6 +883,10 @@ class Query(object):
(not restricted and f.null) or f.rel.parent_link):
continue
table = f.rel.to._meta.db_table
+ if nullable or f.null:
+ promote = True
+ else:
+ promote = False
if model:
int_opts = opts
alias = root_alias
@@ -891,12 +895,12 @@ class Query(object):
int_opts = int_model._meta
alias = self.join((alias, int_opts.db_table, lhs_col,
int_opts.pk.column), exclusions=used,
- promote=f.null)
+ promote=promote)
else:
alias = root_alias
alias = self.join((alias, table, f.column,
f.rel.get_related_field().column), exclusions=used,
- promote=f.null)
+ promote=promote)
used.add(alias)
self.related_select_cols.extend([(alias, f2.column)
for f2 in f.rel.to._meta.fields])
@@ -905,8 +909,12 @@ class Query(object):
next = requested.get(f.name, {})
else:
next = False
+ if f.null is not None:
+ new_nullable = f.null
+ else:
+ new_nullable = None
self.fill_related_selections(f.rel.to._meta, alias, cur_depth + 1,
- used, next, restricted)
+ used, next, restricted, new_nullable)
def add_filter(self, filter_expr, connector=AND, negate=False, trim=False,
can_reuse=None):