Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Malcolm Tredinnick authored February 06, 2008

Showing 1 changed file with 4 additions and 11 deletions. Show diff stats Hide diff stats

  1. 15  django/db/models/query.py
15  django/db/models/query.py
@@ -218,7 +218,6 @@ def in_bulk(self, id_list):
218 218
         qs.query.add_filter(('pk__in', id_list))
219 219
         return dict([(obj._get_pk_val(), obj) for obj in qs.iterator()])
220 220
 
221  
-    # XXX Mostly DONE
222 221
     def delete(self):
223 222
         """
224 223
         Deletes the records in the current QuerySet.
@@ -234,22 +233,16 @@ def delete(self):
234 233
 
235 234
         # Delete objects in chunks to prevent the list of related objects from
236 235
         # becoming too long.
237  
-        more_objects = True
238  
-        while more_objects:
  236
+        while 1:
239 237
             # Collect all the objects to be deleted in this chunk, and all the
240 238
             # objects that are related to the objects that are to be deleted.
241 239
             seen_objs = SortedDict()
242  
-            more_objects = False
243 240
             for object in del_query[:CHUNK_SIZE]:
244  
-                more_objects = True
245 241
                 object._collect_sub_objects(seen_objs)
246 242
 
247  
-            # If one or more objects were found, delete them.
248  
-            # Otherwise, stop looping.
249  
-            # FIXME: Does "if seen_objs:.." work here? If so, we can get rid of
250  
-            # more_objects.
251  
-            if more_objects:
252  
-                delete_objects(seen_objs)
  243
+            if not seen_objs:
  244
+                break
  245
+            delete_objects(seen_objs)
253 246
 
254 247
         # Clear the result cache, in case this QuerySet gets reused.
255 248
         self._result_cache = None

0 notes on commit c23436b

Please sign in to comment.
Something went wrong with that request. Please try again.