Ticket #16891: delete_counts.patch
File delete_counts.patch, 1.1 KB (added by , 13 years ago) |
---|
-
django/db/models/sql/subqueries.py
a b class DeleteQuery(Query): 24 24 def do_query(self, table, where, using): 25 25 self.tables = [table] 26 26 self.where = where 27 self.get_compiler(using).execute_sql(None)27 return self.get_compiler(using).execute_sql(None).cursor.rowcount 28 28 29 29 def delete_batch(self, pk_list, using, field=None): 30 30 """ … … class DeleteQuery(Query): 35 35 """ 36 36 if not field: 37 37 field = self.model._meta.pk 38 39 count = 0 40 38 41 for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): 39 42 where = self.where_class() 40 43 where.add((Constraint(None, field.column, field), 'in', 41 44 pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE]), AND) 42 self.do_query(self.model._meta.db_table, where, using=using) 45 count += self.do_query(self.model._meta.db_table, where, 46 using=using) 47 48 return count 43 49 44 50 class UpdateQuery(Query): 45 51 """