|
@@ -429,7 +429,17 @@ class SQLCompiler:
|
|
|
*self.query.values_select,
|
|
|
*self.query.annotation_select,
|
|
|
))
|
|
|
- parts += (compiler.as_sql(),)
|
|
|
+ part_sql, part_args = compiler.as_sql()
|
|
|
+ if compiler.query.combinator:
|
|
|
+
|
|
|
+
|
|
|
+ if not features.supports_parentheses_in_compound:
|
|
|
+ part_sql = 'SELECT * FROM ({})'.format(part_sql)
|
|
|
+
|
|
|
+
|
|
|
+ elif not features.supports_slicing_ordering_in_compound:
|
|
|
+ part_sql = '({})'.format(part_sql)
|
|
|
+ parts += ((part_sql, part_args),)
|
|
|
except EmptyResultSet:
|
|
|
|
|
|
|