Set up and execute delete queries for all the objects in pk_list. More than one physical query may be executed if there are a lot of values in pk_list.
(self, pk_list, using)
| 25 | return self.get_compiler(using).execute_sql(ROW_COUNT) |
| 26 | |
| 27 | def delete_batch(self, pk_list, using): |
| 28 | """ |
| 29 | Set up and execute delete queries for all the objects in pk_list. |
| 30 | |
| 31 | More than one physical query may be executed if there are a |
| 32 | lot of values in pk_list. |
| 33 | """ |
| 34 | # number of objects deleted |
| 35 | num_deleted = 0 |
| 36 | field = self.get_meta().pk |
| 37 | for offset in range(0, len(pk_list), GET_ITERATOR_CHUNK_SIZE): |
| 38 | self.clear_where() |
| 39 | self.add_filter( |
| 40 | f"{field.attname}__in", |
| 41 | pk_list[offset : offset + GET_ITERATOR_CHUNK_SIZE], |
| 42 | ) |
| 43 | num_deleted += self.do_query( |
| 44 | self.get_meta().db_table, self.where, using=using |
| 45 | ) |
| 46 | return num_deleted |
| 47 | |
| 48 | |
| 49 | class UpdateQuery(Query): |
no test coverage detected