Ticket #16891: delete_counts.patch

File delete_counts.patch, 1.1 KB (added by Steven Cummings, 13 years ago)

Patch to changes so far from git clone

  • django/db/models/sql/subqueries.py

    a b class DeleteQuery(Query):  
    2424    def do_query(self, table, where, using):
    2525        self.tables = [table]
    2626        self.where = where
    27         self.get_compiler(using).execute_sql(None)
     27        return self.get_compiler(using).execute_sql(None).cursor.rowcount
    2828
    2929    def delete_batch(self, pk_list, using, field=None):
    3030        """
    class DeleteQuery(Query):  
    3535        """
    3636        if not field:
    3737            field = self.model._meta.pk
     38
     39        count = 0
     40
    3841        for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE):
    3942            where = self.where_class()
    4043            where.add((Constraint(None, field.column, field), 'in',
    4144                    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
    4349
    4450class UpdateQuery(Query):
    4551    """
Back to Top