diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2010-04-04 17:05:43 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2010-04-04 17:05:43 +0000 |
| commit | 82efb4840311d549989ccf224fa78765226f6040 (patch) | |
| tree | 93dd63f8531e8f073be33d1a732ab95972000cb0 /django/db/models/sql/compiler.py | |
| parent | f92d73fbd48aa22c4f0d6b155e795b65ecc6355c (diff) | |
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).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12912 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/sql/compiler.py')
| -rw-r--r-- | django/db/models/sql/compiler.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 84c28a0d35..8a24c62fe5 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -120,13 +120,15 @@ class SQLCompiler(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.query.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.get_compiler(connection=self.connection).as_sql() |
