summaryrefslogtreecommitdiff
path: root/django/db/models/sql
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-04-04 17:17:46 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-04-04 17:17:46 +0000
commit0d6a776ccd9a6035b97389ca57fee41dd7454e01 (patch)
tree9edbfb153b78c35579e81e1988edf4bcf4073cb7 /django/db/models/sql
parent17636ef9991f7b051b8c8032f75b62c5ab073c7c (diff)
[1.1.X] Fixed #12328 -- Corrected the handling of subqueries with ordering and slicing, especially when used in delete subqueries. Thanks to Walter Doekes for the report.
This fixes a feature that isn't available under MySQL and Oracle (Refs #10099). Backport of r12912 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12914 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql')
-rw-r--r--django/db/models/sql/query.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 9a2ac81c2b..131e97a438 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -456,13 +456,14 @@ class BaseQuery(object):
"""
Perform the same functionality as the as_sql() method, returning an
SQL string and parameters. However, the alias prefixes are bumped
- beforehand (in a copy -- the current query isn't changed) and any
- ordering is removed.
-
+ beforehand (in a copy -- the current query isn't changed), and any
+ ordering is removed if the query is unsliced.
Used when nesting this query inside another.
"""
obj = self.clone()
- obj.clear_ordering(True)
+ if obj.low_mark == 0 and obj.high_mark is None:
+ # If there is no slicing in use, then we can safely drop all ordering
+ obj.clear_ordering(True)
obj.bump_prefix()
return obj.as_sql()