summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
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 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: