Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate relations if multiple indexes on foreign key #35

Open
cyrillbolliger opened this issue Mar 30, 2024 · 0 comments · Fixed by cyrillbolliger/planter#1 · May be fixed by #36
Open

Duplicate relations if multiple indexes on foreign key #35

cyrillbolliger opened this issue Mar 30, 2024 · 0 comments · Fixed by cyrillbolliger/planter#1 · May be fixed by #36

Comments

@cyrillbolliger
Copy link

Many thanks for this super handy project!

I noticed a small bug: If there are two indexes on a foreign key, the relation is duplicated even though there is only one foreign key column. Here a minimal example to reproduce the issue:

For the following table definition

create table foo
(
    id serial primary key
);

create table bar
(
    id     serial primary key,
    foo_id int references foo,
    name   int
);

create index on bar (foo_id);
create unique index on bar (name, foo_id);

planter creates the following output

@startuml
hide circle
skinparam linetype ortho

entity "**bar**" {
  + ""id"": //serial [PK]//
  --
  ""foo_id"": //integer [FK]//
  ""name"": //integer //
}

entity "**foo**" {
  + ""id"": //serial [PK]//
  --
}

"**bar**"   }--  "**foo**"

"**bar**"   }--  "**foo**"
@enduml

whereas the correct output would be

@startuml
hide circle
skinparam linetype ortho

entity "**bar**" {
  + ""id"": //serial [PK]//
  --
  ""foo_id"": //integer [FK]//
  ""name"": //integer //
}

entity "**foo**" {
  + ""id"": //serial [PK]//
  --
}

"**bar**"   }--  "**foo**"
@enduml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant