#17140 closed Bug (duplicate)
Unexpected behaviour with on_delete handlers and proxy models (IntegrityError)
| Reported by: | Jaap Roes | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.3 |
| Severity: | Normal | Keywords: | ForeignKey on_delete proxy model IntegrityError CASCADE SET_NULL |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Let's say I have a File model and an Image model. The second one being a proxy to the File model, with some additional methods and a manager that only return image-like files.
Another model has a ForeignKey to the Image model. Deleting an Image will trigger the on_delete handlers of it's foreign keys, cascades happen and everything is fine.
Deleting the same thing as an instance of File however will not clean up every objects linking to it. Instead an IntegrityError is raised. It's obvious that the File doesn't know it's also an Image and therefore doesn't trigger the on_delete handler of foreign keys referring to it by a different name.
I don't really see a nice way to work around or fix this problem.
Attachments (1)
Change History (5)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:3 by , 14 years ago
| Resolution: | → duplicate |
|---|---|
| Status: | new → closed |
I'm not sure I see how this is the reverse of #16128. If I'm reading that one right, the failure is in the exact same case: FK pointing to proxy model, real parent of proxy deleted. I think this is a duplicate of that ticket.
comment:4 by , 14 years ago
Yes, it seems to be a duplicate. I think I got confused after reading the comments and the patches of the other ticket.
I've expended my testcases to include the proxy of proxy case, and will attach it to the other bug. Thanks!
This seems related (but in reverse) to ticket #16128