related models with Foreignkey.null=True must not get deleted on delete of their relation
|Reported by:||defaultwombat||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.1|
|Severity:||Keywords:||delete foreignkey null|
|Cc:||kanu@…, plandry@…||Triage Stage:||Unreviewed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The "delete related objects" process appears bugged to me.
In some lines of the code it looks like the intention was to set foreignkeys of related objects to null if possible, instead of deleting the object. Nevertheless the deletion does happen.
This is only about Realtions with Foreignkey(..,null=True). Other relations work as intended.
Related Objects get deleted during delete_objects()
Subrelation of related objects get collected during _collect_sub_objects()
Please have a look at the test file.