summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2017-11-12 14:28:11 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2017-11-12 14:33:41 +0100
commit67316720603821ebb64dfe8fa592ba6edcef5f3e (patch)
tree02ec6368544391e560a0ffda127ac24ac8eaa7ec /django
parent308f64462421b09b21ef0dcd9cc3654cc25bceba (diff)
[1.11.x] Fixed #28781 -- Added QuerySet.values()/values_list() support for union(), difference(), and intersection().
Thanks Tim Graham for the review. Backport of 2d3cc94284674638c334670903d49565039d77ae from master
Diffstat (limited to 'django')
-rw-r--r--django/db/models/sql/compiler.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 6ec2284a91..9888816c8d 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -390,6 +390,11 @@ class SQLCompiler(object):
parts = ()
for compiler in compilers:
try:
+ # If the columns list is limited, then all combined queries
+ # must have the same columns list. Set the selects defined on
+ # the query on all combined queries, if not already set.
+ if not compiler.query.values_select and self.query.values_select:
+ compiler.query.set_values(self.query.values_select)
parts += (compiler.as_sql(),)
except EmptyResultSet:
# Omit the empty queryset with UNION and with DIFFERENCE if the