summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 03:31:37 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2007-10-15 03:31:37 +0000
commitf74464da52e28c513ee008022ce70717672e346e (patch)
treefc2aab713d8e229ceee0c4bffc60da1201be2437
parent70d5e32e13426372d3d98bb7664d8a69975ed885 (diff)
queryset-refactor: Fixed values(...).select_related(...) bug that was
introduced in [6512]. The lookup tests picked this up. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6517 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/models/query.py1
-rw-r--r--django/db/models/sql/query.py4
2 files changed, 4 insertions, 1 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 9a590ddd26..f96e91e55c 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -416,6 +416,7 @@ class ValuesQuerySet(QuerySet):
field_names = [f.attname for f in fields]
self.query.add_local_columns([f.column for f in fields])
+ self.query.default_cols = False
self.field_names = field_names
def _clone(self, klass=None, setup=False, **kwargs):
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index b7f346a632..f11da3be29 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -75,6 +75,7 @@ class Query(object):
self.table_map = {} # Maps table names to list of aliases.
self.join_map = {} # Maps join_tuple to list of aliases.
self.rev_join_map = {} # Reverse of join_map.
+ self.default_cols = True
# SQL-related attributes
self.select = []
@@ -129,6 +130,7 @@ class Query(object):
obj.alias_map = copy.deepcopy(self.alias_map)
obj.join_map = copy.deepcopy(self.join_map)
obj.rev_join_map = copy.deepcopy(self.rev_join_map)
+ obj.default_cols = self.default_cols
obj.select = self.select[:]
obj.tables = self.tables[:]
obj.where = copy.deepcopy(self.where)
@@ -353,7 +355,7 @@ class Query(object):
result.append(col.as_sql(quote_func=qn))
if hasattr(col, 'alias'):
aliases.append(col.alias)
- else:
+ elif self.default_cols:
table_alias = self.tables[0]
result = ['%s.%s' % (qn(table_alias), qn(f.column))
for f in self.model._meta.fields]