summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorJustin Hamade <justhamade@gmail.com>2014-04-14 16:11:52 -0400
committerSimon Charette <charette.s@gmail.com>2014-04-16 18:02:25 -0400
commit7f8bd1a4b39ed834dffa0adc8fa19ef6b807f45d (patch)
treead86d304c4c32d20ef3d2eaef5b432e198c8725f /django/db/models/sql
parent841e21a85c17c87f8b7b41b5cbb5eae15888f9b7 (diff)
[1.7.x] Fixed #22434 -- Retain ordering on related sliced subqueries.
Thanks maciej.pawlisz for the report, and charettes for the review. Backport of a13df671a5 from master
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/where.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 2b315be7c8..0fedb771b7 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -418,7 +418,9 @@ class SubqueryConstraint(object):
else:
query = query._clone()
query = query.query
- query.clear_ordering(True)
+ if query.can_filter():
+ # If there is no slicing in use, then we can safely drop all ordering
+ query.clear_ordering(True)
query_compiler = query.get_compiler(connection=connection)
return query_compiler.as_subquery_condition(self.alias, self.columns, qn)