Opened 3 years ago
Last modified 3 years ago
#33187 closed Bug
Foreign key to a specific field is not handled in inspectdb — at Version 3
Reported by: | Thierry Bastian | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 3.2 |
Severity: | Normal | Keywords: | |
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 (last modified by )
if you have a DB like that
CREATE TABLE foo ( id serial primary key, other_id int UNIQUE); CREATE TABLE bar ( id serial primary key, other_id int, constraint myconst FOREIGN KEY(other_id) references foo(other_id) );
the generated model for the bar table will have the other_id be a FK to foo and not foo(other_id).
I'm attaching a potential fix for this. Sorry I had no time for the UTs.
Change History (4)
by , 3 years ago
Attachment: | handle_fk_to_field.diff added |
---|
comment:1 by , 3 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
it seems I cannot reproduce outside of my own code...
comment:2 by , 3 years ago
Resolution: | invalid |
---|---|
Status: | closed → new |
comment:3 by , 3 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Description: | modified (diff) |
Summary: | Foreign key to a specific field is not handled in inspected → Foreign key to a specific field is not handled in inspectdb |
Type: | Uncategorized → Bug |
Note:
See TracTickets
for help on using tickets.
simple patch to handle FK to non pk field.