diff options
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index e4605918d9..e9f99fa838 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -535,8 +535,8 @@ class SQLCompiler: if not query.is_empty() ] if not features.supports_slicing_ordering_in_compound: - for query, compiler in zip(self.query.combined_queries, compilers): - if query.low_mark or query.high_mark: + for compiler in compilers: + if compiler.query.is_sliced: raise DatabaseError( "LIMIT/OFFSET not allowed in subqueries of compound statements." ) @@ -544,6 +544,11 @@ class SQLCompiler: raise DatabaseError( "ORDER BY not allowed in subqueries of compound statements." ) + elif self.query.is_sliced and combinator == "union": + limit = (self.query.low_mark, self.query.high_mark) + for compiler in compilers: + if not compiler.query.is_sliced: + compiler.query.set_limits(*limit) parts = () for compiler in compilers: try: |
