summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2015-01-30 14:26:13 +0700
committerLoic Bistuer <loic.bistuer@gmail.com>2015-01-30 22:02:58 +0700
commit4c3bfe9053766d378999d06ec34ee5fd4e39f511 (patch)
tree7fd907b4c1dc0ac93d01a4b2de960e7894b3af8a /django/db/models/sql
parentdbabf43920bfd99f0e720c7c20228c17128a2af8 (diff)
Fixed #24211 -- Removed ValuesQuerySet() and ValuesListQuerySet().
Thanks Anssi Kääriäinen, Marc Tamlyn, and Tim Graham for the reviews.
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py13
-rw-r--r--django/db/models/sql/where.py2
2 files changed, 10 insertions, 5 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index f7d5556e0a..b5ece24a0e 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -148,7 +148,14 @@ class Query(object):
self.distinct_fields = []
self.select_for_update = False
self.select_for_update_nowait = False
+
self.select_related = False
+ # Arbitrary limit for select_related to prevents infinite recursion.
+ self.max_depth = 5
+
+ # Holds the selects defined by a call to values() or values_list()
+ # excluding annotation_select and extra_select.
+ self.values_select = []
# SQL annotation-related attributes
# The _annotations will be an OrderedDict when used. Due to the cost
@@ -158,10 +165,6 @@ class Query(object):
self.annotation_select_mask = None
self._annotation_select_cache = None
- # Arbitrary maximum limit for select_related. Prevents infinite
- # recursion. Can be changed by the depth parameter to select_related().
- self.max_depth = 5
-
# These are for extensions. The contents are more or less appended
# verbatim to the appropriate clause.
# The _extra attribute is an OrderedDict, lazily created similarly to
@@ -273,6 +276,7 @@ class Query(object):
obj.select_for_update = self.select_for_update
obj.select_for_update_nowait = self.select_for_update_nowait
obj.select_related = self.select_related
+ obj.values_select = self.values_select[:]
obj._annotations = self._annotations.copy() if self._annotations is not None else None
if self.annotation_select_mask is None:
obj.annotation_select_mask = None
@@ -1616,6 +1620,7 @@ class Query(object):
columns.
"""
self.select = []
+ self.values_select = []
def add_select(self, col):
self.default_cols = False
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index fe428b2418..3b894b8aed 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -204,7 +204,7 @@ class SubqueryConstraint(object):
if query._db and connection.alias != query._db:
raise ValueError("Can't do subqueries with queries on different DBs.")
# Do not override already existing values.
- if not hasattr(query, 'field_names'):
+ if query._fields is None:
query = query.values(*self.targets)
else:
query = query._clone()