#31866 closed Bug (fixed)
Proxy model is ignored when referenced in select_for_update's 'of' parameter
Reported by: | Daniel Hillier | Owned by: | Daniel Hillier |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 2.2 |
Severity: | Normal | Keywords: | proxy select_for_update |
Cc: | 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
When referring to a proxy model as a FK in a select_for_update()
call, the proxy model's table is silently omitted from the FOR UPDATE
clause in the resulting SQL.
Also, if a model has a FK to a proxy model, the FieldError
that is supposed to be raised when an any inappropriate field is found in a select_for_update()
call will crash with AttributeError: 'NoneType' object has no attribute 'name'
.
Tested with postgres but I don't think this is specific to that db.
Change History (10)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Submitted a pull request with a fix: https://github.com/django/django/pull/13283
comment:3 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Patch is looking good to me. Thanks for your great patch and test Daniel.
Created branch with failing tests here: https://github.com/danifus/django/tree/b31866