summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-05-20 14:24:48 +0300
committerAnssi Kääriäinen <akaariai@gmail.com>2013-05-20 15:38:47 +0300
commitf53059b41148da77e8c4cdfcdbec3a7514cd97c9 (patch)
treeff8d88fc23a439d5f67e162a20443c5625aac4e9 /django
parenta93672622829e0d4a2ff3240456d4d73b9d46476 (diff)
Fixed qs.values() regression when used in subquery
Diffstat (limited to 'django')
-rw-r--r--django/db/models/sql/where.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index ff3d1bdcfb..08f9d6c837 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -399,7 +399,12 @@ class SubqueryConstraint(object):
if hasattr(query, 'values'):
if query._db and connection.alias != query._db:
raise ValueError("Can't do subqueries with queries on different DBs.")
- query = query.values(*self.targets).query
+ # Do not override already existing values.
+ if not hasattr(query, 'field_names'):
+ query = query.values(*self.targets)
+ else:
+ query = query._clone()
+ query = query.query
query.clear_ordering(True)
query_compiler = query.get_compiler(connection=connection)