Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

magic-removal: Fixed #1358 -- Fixed Python 2.3 incompatibility in dja…

…ngo.db.models.query. Thanks, Christopher Lenz

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2308 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0604002cedcae907fa8a5e63766f76994cba538b 1 parent a1d9de4
Adrian Holovaty authored

Showing 1 changed file with 15 additions and 16 deletions. Show diff stats Hide diff stats

  1. 31  django/db/models/query.py
31  django/db/models/query.py
@@ -178,7 +178,7 @@ def delete(self):
178 178
         """
179 179
         Deletes the records in the current QuerySet.
180 180
         """
181  
-        del_query = self._clone()        
  181
+        del_query = self._clone()
182 182
 
183 183
         # disable non-supported fields
184 184
         del_query._select_related = False
@@ -186,19 +186,19 @@ def delete(self):
186 186
         del_query._offset = None
187 187
         del_query._limit = None
188 188
 
189  
-        # Collect all the objects to be deleted, and all the objects that are related to 
  189
+        # Collect all the objects to be deleted, and all the objects that are related to
190 190
         # the objects that are to be deleted
191 191
         seen_objs = {}
192 192
         for object in del_query:
193 193
             object._collect_sub_objects(seen_objs)
194  
-        
195  
-        # Delete the objects    
  194
+
  195
+        # Delete the objects
196 196
         delete_objects(seen_objs)
197  
-        
  197
+
198 198
         # Clear the result cache, in case this QuerySet gets reused.
199 199
         self._result_cache = None
200 200
     delete.alters_data = True
201  
-        
  201
+
202 202
     ##################################################
203 203
     # PUBLIC METHODS THAT RETURN A QUERYSET SUBCLASS #
204 204
     ##################################################
@@ -776,11 +776,11 @@ def delete_objects(seen_objs):
776 776
     ordered_classes.sort(compare_models)
777 777
 
778 778
     cursor = connection.cursor()
779  
-     
  779
+
780 780
     for cls in ordered_classes:
781 781
         seen_objs[cls] = seen_objs[cls].items()
782 782
         seen_objs[cls].sort()
783  
-    
  783
+
784 784
         # Pre notify all instances to be deleted
785 785
         for pk_val, instance in seen_objs[cls]:
786 786
             dispatcher.send(signal=signals.pre_delete, sender=cls, instance=instance)
@@ -790,34 +790,33 @@ def delete_objects(seen_objs):
790 790
             cursor.execute("DELETE FROM %s WHERE %s IN (%s)" % \
791 791
                 (backend.quote_name(related.field.get_m2m_db_table(related.opts)),
792 792
                     backend.quote_name(cls._meta.object_name.lower() + '_id'),
793  
-                    ','.join('%s' for pk in pk_list)), 
  793
+                    ','.join(['%s' for pk in pk_list])),
794 794
                 pk_list)
795 795
         for f in cls._meta.many_to_many:
796 796
             cursor.execute("DELETE FROM %s WHERE %s IN (%s)" % \
797 797
                 (backend.quote_name(f.get_m2m_db_table(cls._meta)),
798 798
                     backend.quote_name(cls._meta.object_name.lower() + '_id'),
799  
-                    ','.join(['%s' for pk in pk_list])), 
  799
+                    ','.join(['%s' for pk in pk_list])),
800 800
                 pk_list)
801 801
         for field in cls._meta.fields:
802 802
             if field.rel and field.null and field.rel.to in seen_classes:
803 803
                 cursor.execute("UPDATE %s SET %s=NULL WHERE %s IN (%s)" % \
804  
-                    (backend.quote_name(cls._meta.db_table), 
  804
+                    (backend.quote_name(cls._meta.db_table),
805 805
                         backend.quote_name(field.column),
806  
-                        backend.quote_name(cls._meta.pk.column), 
807  
-                        ','.join(['%s' for pk in pk_list])), 
  806
+                        backend.quote_name(cls._meta.pk.column),
  807
+                        ','.join(['%s' for pk in pk_list])),
808 808
                     pk_list)
809 809
 
810 810
     # Now delete the actual data
811 811
     for cls in ordered_classes:
812 812
         seen_objs[cls].reverse()
813 813
         pk_list = [pk for pk,instance in seen_objs[cls]]
814  
-        
815 814
         cursor.execute("DELETE FROM %s WHERE %s IN (%s)" % \
816  
-            (backend.quote_name(cls._meta.db_table), 
  815
+            (backend.quote_name(cls._meta.db_table),
817 816
                 backend.quote_name(cls._meta.pk.column),
818 817
                 ','.join(['%s' for pk in pk_list])),
819 818
             pk_list)
820  
-                
  819
+
821 820
         # Last cleanup; set NULLs where there once was a reference to the object,
822 821
         # NULL the primary key of the found objects, and perform post-notification.
823 822
         for pk_val, instance in seen_objs[cls]:

0 notes on commit 0604002

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