summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorAstral <AmrAnwar@users.noreply.github.com>2018-03-20 04:05:43 +0300
committerTim Graham <timograham@gmail.com>2018-03-19 21:05:43 -0400
commita0c03c62a8ac586e5be5b21393c925afa581efaf (patch)
treeaeb02cac3280557d39ccd20ab2ec18345ba848e9 /django/db/models/sql
parentcede5111bbeea1f02a7d35941a4264c7ff95df0a (diff)
Fixed #29229 -- Fixed column mismatch crash when combining two annotated values_list() querysets with union(), difference(), or intersection().
Regression in 7316720603821ebb64dfe8fa592ba6edcef5f3e.
Diffstat (limited to 'django/db/models/sql')
-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 1fdbd156b6..aeb1a723f9 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -408,7 +408,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: