7 | | If you want to give a shot at a patch you'll want to have a look at `Collector.collect` and have it skip collection entirely when dealing with `SET` and friends likely by adding a branch that turns them into ''fast'' updates. [https://github.com/django/django/blob/08688bd7dd8dfa218ecff03d6c94a753b1be8e59/django/db/models/deletion.py#L500-L504 One branch that worries me is the post-deletion assignment of values to in-memory instances] but I can't understand why this is even necessary given all the instances that are collected for field updates are never make their way out of the collector so I would expect it to be entirely unnecessary. |
| 7 | If you want to give a shot at a patch you'll want to have a look at `Collector.collect` and have it skip collection entirely when dealing with `SET` and friends likely by adding a branch that turns them into ''fast'' updates. [https://github.com/django/django/blob/08688bd7dd8dfa218ecff03d6c94a753b1be8e59/django/db/models/deletion.py#L500-L504 One branch that worries me is the post-deletion assignment of values to in-memory instances] but I can't understand why this is even necessary given all the instances that are collected for field updates are never make their way out of the collector so I would expect it to be entirely unnecessary at least all `delete` and `delete_regress` tests pass if I entirely remove it |
| 8 | |
| 9 | {{{#!diff |
| 10 | diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py |
| 11 | index 2cb3c88444..2eb8e95281 100644 |
| 12 | --- a/django/db/models/deletion.py |
| 13 | +++ b/django/db/models/deletion.py |
| 14 | @@ -496,12 +496,6 @@ def delete(self): |
| 15 | using=self.using, |
| 16 | origin=self.origin, |
| 17 | ) |
| 18 | - |
| 19 | - # update collected instances |
| 20 | - for instances_for_fieldvalues in self.field_updates.values(): |
| 21 | - for (field, value), instances in instances_for_fieldvalues.items(): |
| 22 | - for obj in instances: |
| 23 | - setattr(obj, field.attname, value) |
| 24 | for model, instances in self.data.items(): |
| 25 | for instance in instances: |
| 26 | setattr(instance, model._meta.pk.attname, None) |
| 27 | }}} |