summaryrefslogtreecommitdiff
path: root/django/db/models/sql/compiler.py
diff options
context:
space:
mode:
authorAmr Anwar <amranwar945@gmail.com>2018-03-19 09:58:50 -0400
committerTim Graham <timograham@gmail.com>2018-03-19 21:05:59 -0400
commit9123fd75caa595c018d4121575cbada80226b4f2 (patch)
tree209cca5b52f5e6eb8a90c817a3641bd6eb4c396c /django/db/models/sql/compiler.py
parent80cd6fd55af80218d24fd8ce9bb93b7704e939df (diff)
[2.0.x] Fixed #29229 -- Fixed column mismatch crash when combining two annotated values_list() querysets with union(), difference(), or intersection().
Regression in 7316720603821ebb64dfe8fa592ba6edcef5f3e. Backport of a0c03c62a8ac586e5be5b21393c925afa581efaf from master
Diffstat (limited to 'django/db/models/sql/compiler.py')
-rw-r--r--django/db/models/sql/compiler.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 72a6537e05..fa3f4fb739 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -411,7 +411,8 @@ class SQLCompiler:
# 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:
+ if (not compiler.query.values_select and not compiler.query.annotations and
+ self.query.values_select):
compiler.query.set_values(self.query.values_select)
parts += (compiler.as_sql(),)
except EmptyResultSet: