mirror of
https://github.com/django/django.git
synced 2025-07-06 10:49:17 +00:00
queryset-refactor: Removed another FIXME.
This time, simplifying the delete() method. git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7092 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
04a55d663f
commit
c23436be59
@ -218,7 +218,6 @@ class _QuerySet(object):
|
|||||||
qs.query.add_filter(('pk__in', id_list))
|
qs.query.add_filter(('pk__in', id_list))
|
||||||
return dict([(obj._get_pk_val(), obj) for obj in qs.iterator()])
|
return dict([(obj._get_pk_val(), obj) for obj in qs.iterator()])
|
||||||
|
|
||||||
# XXX Mostly DONE
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
"""
|
"""
|
||||||
Deletes the records in the current QuerySet.
|
Deletes the records in the current QuerySet.
|
||||||
@ -234,22 +233,16 @@ class _QuerySet(object):
|
|||||||
|
|
||||||
# Delete objects in chunks to prevent the list of related objects from
|
# Delete objects in chunks to prevent the list of related objects from
|
||||||
# becoming too long.
|
# becoming too long.
|
||||||
more_objects = True
|
while 1:
|
||||||
while more_objects:
|
|
||||||
# Collect all the objects to be deleted in this chunk, and all the
|
# Collect all the objects to be deleted in this chunk, and all the
|
||||||
# objects that are related to the objects that are to be deleted.
|
# objects that are related to the objects that are to be deleted.
|
||||||
seen_objs = SortedDict()
|
seen_objs = SortedDict()
|
||||||
more_objects = False
|
|
||||||
for object in del_query[:CHUNK_SIZE]:
|
for object in del_query[:CHUNK_SIZE]:
|
||||||
more_objects = True
|
|
||||||
object._collect_sub_objects(seen_objs)
|
object._collect_sub_objects(seen_objs)
|
||||||
|
|
||||||
# If one or more objects were found, delete them.
|
if not seen_objs:
|
||||||
# Otherwise, stop looping.
|
break
|
||||||
# FIXME: Does "if seen_objs:.." work here? If so, we can get rid of
|
delete_objects(seen_objs)
|
||||||
# more_objects.
|
|
||||||
if more_objects:
|
|
||||||
delete_objects(seen_objs)
|
|
||||||
|
|
||||||
# Clear the result cache, in case this QuerySet gets reused.
|
# Clear the result cache, in case this QuerySet gets reused.
|
||||||
self._result_cache = None
|
self._result_cache = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user