#30330 closed Bug (fixed)
delete() on instances of models without any dependencies doesn't clear PKs.
Reported by: | Artur | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.2 |
Severity: | Release blocker | Keywords: | delete, pk |
Cc: | Florian Apolloner | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Deleting any model with no dependencies not updates the PK on the model. It should be set to None
after .delete()
call.
See Django.db.models.deletion:276-281. Should update the model line 280.
Attachments (2)
Change History (9)
comment:1 by , 6 years ago
Cc: | added |
---|---|
Severity: | Normal → Release blocker |
Summary: | Deletion isn't updating model → delete() on instances of models without any dependencies doesn't clear PKs. |
Triage Stage: | Unreviewed → Accepted |
by , 6 years ago
Attachment: | fix-30330.diff added |
---|
comment:3 by , 6 years ago
I have attached a simple fix which mimics what https://github.com/django/django/blob/master/django/db/models/deletion.py#L324-L326 does for multiple objects. I am not sure if we need https://github.com/django/django/blob/master/django/db/models/deletion.py#L320-L323 (the block above) because I think field_updates
is only ever filled if the objects are not fast-deletable -- ie https://github.com/django/django/blob/master/django/db/models/deletion.py#L224 is not called due to the can_fast_delete
check at the beginning of the collect
function.
That said, if we want to be extra "safe" we can just move lines 320 - 326 into an extra function and call that from the old and new location (though I do not think it is needed).
comment:5 by , 6 years ago
Has patch: | set |
---|
comment:6 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Reproduced at 1ffddfc233e2d5139cc6ec31a4ec6ef70b10f87f.
Regression in bc7dd8490b882b2cefdc7faf431dc64c532b79c9.
Thanks for the report.