Multicolumn unique indexes are not handled correctly
James-REANNZ opened this issue · comments
James-REANNZ commented
If a unique index contains multiple columns, then all the columns are marked as being independently unique. This leads to incorrect code generation when one of the columns is a foreign key, as it implies a one-to-one relationship.
create table example (
id integer not null primary key,
other_id integer not null references other(id),
type text not null,
constraint other_type_unique unique (other_id, type)
);
Leads to code that looks like this:
type otherR struct {
Example *Example
}
in other.go
instead of:
type otherR struct {
Examples ExampleSlice
}