mirror of
https://github.com/django/django.git
synced 2025-09-26 20:19:16 +00:00
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
This commit is contained in:
parent
f92d73fbd4
commit
82efb48403
6 changed files with 58 additions and 12 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue