summaryrefslogtreecommitdiff
path: root/django/db/models/query.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-04-04 17:05:43 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-04-04 17:05:43 +0000
commit82efb4840311d549989ccf224fa78765226f6040 (patch)
tree93dd63f8531e8f073be33d1a732ab95972000cb0 /django/db/models/query.py
parentf92d73fbd48aa22c4f0d6b155e795b65ecc6355c (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.py9
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