| 1 | 1002,1025c1002,1016
|
|---|
| 2 | < perform_delete = True
|
|---|
| 3 | <
|
|---|
| 4 | < if cls._meta.managed == False:
|
|---|
| 5 | < check_view = "select count(TABLE_NAME) from INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '%s';" % cls._meta.db_table
|
|---|
| 6 | < cursor = connection.cursor()
|
|---|
| 7 | < cursor.execute(check_view, [])
|
|---|
| 8 | < if not cursor.rowcount == 0:
|
|---|
| 9 | < perform_delete = False
|
|---|
| 10 | <
|
|---|
| 11 | < if perform_delete:
|
|---|
| 12 | < pk_list = [pk for pk,instance in items]
|
|---|
| 13 | < del_query = sql.DeleteQuery(cls, connection)
|
|---|
| 14 | < del_query.delete_batch(pk_list)
|
|---|
| 15 | <
|
|---|
| 16 | < # Last cleanup; set NULLs where there once was a reference to the
|
|---|
| 17 | < # object, NULL the primary key of the found objects, and perform
|
|---|
| 18 | < # post-notification.
|
|---|
| 19 | < for pk_val, instance in items:
|
|---|
| 20 | < for field in cls._meta.fields:
|
|---|
| 21 | < if field.rel and field.null and field.rel.to in seen_objs:
|
|---|
| 22 | < setattr(instance, field.attname, None)
|
|---|
| 23 | <
|
|---|
| 24 | < signals.post_delete.send(sender=cls, instance=instance)
|
|---|
| 25 | < setattr(instance, cls._meta.pk.attname, None)
|
|---|
| 26 | ---
|
|---|
| 27 | >
|
|---|
| 28 | > pk_list = [pk for pk,instance in items]
|
|---|
| 29 | > del_query = sql.DeleteQuery(cls, connection)
|
|---|
| 30 | > del_query.delete_batch(pk_list)
|
|---|
| 31 | >
|
|---|
| 32 | > # Last cleanup; set NULLs where there once was a reference to the
|
|---|
| 33 | > # object, NULL the primary key of the found objects, and perform
|
|---|
| 34 | > # post-notification.
|
|---|
| 35 | > for pk_val, instance in items:
|
|---|
| 36 | > for field in cls._meta.fields:
|
|---|
| 37 | > if field.rel and field.null and field.rel.to in seen_objs:
|
|---|
| 38 | > setattr(instance, field.attname, None)
|
|---|
| 39 | >
|
|---|
| 40 | > signals.post_delete.send(sender=cls, instance=instance)
|
|---|
| 41 | > setattr(instance, cls._meta.pk.attname, None)
|
|---|