Opened 4 years ago
Last modified 4 years ago
#33187 closed Bug
Foreign key to a specific field is not handled in inspected — at Initial Version
| 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
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.
Note:
See TracTickets
for help on using tickets.
simple patch to handle FK to non pk field.