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/query.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/query.py')
| -rw-r--r-- | django/db/models/query.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py index 3567671a1a..b8b2340b3f 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -3,6 +3,7 @@ The main QuerySet implementation. This provides the public API for the ORM. """ from copy import deepcopy +from itertools import izip from django.db import connections, router, transaction, IntegrityError from django.db.models.aggregates import Aggregate @@ -429,11 +430,13 @@ class QuerySet(object): # becoming too long. seen_objs = None while 1: - # Collect all the objects to be deleted in this chunk, and all the + # Collect a chunk of objects to be deleted, and then all the # objects that are related to the objects that are to be deleted. + # The chunking *isn't* done by slicing the del_query because we + # need to maintain the query cache on del_query (see #12328) seen_objs = CollectedObjects(seen_objs) - for object in del_query[:CHUNK_SIZE]: - object._collect_sub_objects(seen_objs) + for i, obj in izip(xrange(CHUNK_SIZE), del_query): + obj._collect_sub_objects(seen_objs) if not seen_objs: break |
