diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-18 12:46:40 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-03-18 12:46:40 +0000 |
| commit | bec21f0e2b5ab44565066cdab25ec6746d96efcc (patch) | |
| tree | 8cf1666775f91a075f7e21435cc03c02f4763925 /django/db/models/sql | |
| parent | 67cc3cec90c02201a27816552ed78b9ef7519927 (diff) | |
queryset-refactor: Fixed problems with values() queries across nullable relations.
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7287 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index c153fe1e55..296eb285e1 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -1171,7 +1171,20 @@ class Query(object): u1, target, u2, joins, u3 = self.setup_joins( name.split(LOOKUP_SEP), opts, alias, False, allow_m2m, True) - self.select.append((joins[-1], target.column)) + final_alias = joins[-1] + col = target.column + if len(joins) > 1: + join = self.alias_map[final_alias] + if col == join[RHS_JOIN_COL]: + self.unref_alias(final_alias) + final_alias = join[LHS_ALIAS] + col = join[LHS_JOIN_COL] + joins = joins[:-1] + for join in joins[1:]: + # Only nullable aliases are promoted, so we don't end up + # doing unnecessary left outer joins here. + self.promote_alias(join) + self.select.append((final_alias, col)) except MultiJoin: raise FieldError("Invalid field name: '%s'" % name) |
