Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit c23436be59b4a5c3b399a8849812594bd396e419 1 parent 04a55d6
@malcolmt malcolmt authored
Showing with 4 additions and 11 deletions.
  1. +4 −11 django/db/models/query.py
View
15 django/db/models/query.py
@@ -218,7 +218,6 @@ def in_bulk(self, id_list):
qs.query.add_filter(('pk__in', id_list))
return dict([(obj._get_pk_val(), obj) for obj in qs.iterator()])
- # XXX Mostly DONE
def delete(self):
"""
Deletes the records in the current QuerySet.
@@ -234,22 +233,16 @@ def delete(self):
# Delete objects in chunks to prevent the list of related objects from
# becoming too long.
- more_objects = True
- while more_objects:
+ while 1:
# 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.
seen_objs = SortedDict()
- more_objects = False
for object in del_query[:CHUNK_SIZE]:
- more_objects = True
object._collect_sub_objects(seen_objs)
- # If one or more objects were found, delete them.
- # Otherwise, stop looping.
- # FIXME: Does "if seen_objs:.." work here? If so, we can get rid of
- # more_objects.
- if more_objects:
- delete_objects(seen_objs)
+ if not seen_objs:
+ break
+ delete_objects(seen_objs)
# Clear the result cache, in case this QuerySet gets reused.
self._result_cache = None
Please sign in to comment.
Something went wrong with that request. Please try again.