achiku/planter

All relations are duplicated

asitemade4u opened this issue · 3 comments

Hi,
Thank you so very much for this very useful program!

Everything works well with one exception: all relations are duplicated and I cannot figure why.
Here is a simple example from a much larger PostgreSQL database:

  • I have a table TAG, with a PK tag_key
  • I have a table CTG (= categories), with a PK ctg_key
  • There is a relationship of many to 0/1 between TAG and CTG, defined using a foreign key tag_fk: each tag belongs or not to a category
  • both table belong to a schema kuq

Here is the TAG DDL for TAG:

CREATE TABLE kuq.tag (
	tag_key int4 NOT NULL,
	ctg_key int4 NULL,
	tag varchar(60) NULL,
	CONSTRAINT tag_pk PRIMARY KEY (tag_key),
	CONSTRAINT tag_un UNIQUE (tag_key)
);
CREATE INDEX tag_tag_idx ON kuq.tag USING btree (tag);

ALTER TABLE kuq.tag ADD CONSTRAINT tag_fk FOREIGN KEY (ctg_key) REFERENCES kuq.ctg(ctg_key);

When I execute:

planter postgres://<connection>?sslmode=disable \
-s kuq    \
-t tag    \
-t ctg    \
-o test.uml

I get this PlantUML schema where the many to one link between TAG and CTG is duplicated:

image

And, in effect, the link is duplicated in the UML definition file:

@startuml

entity "ctg" {
  Tag Categories
  ..
  + ctg_key [PK]
  --
  ctg_key
  nam
  cmt
}

entity "tag" {
  Tags
  ..
  + tag_key [PK]
  --
  tag_key
  ctg_key
  tag
}

tag }-- ctg
tag }-- ctg

@enduml

What am I doing wrong?
Best,
Stephen

@asitemade4u I tried it with the current master branch at commit at commit c43fae7 , but couldn't reproduce it. Could you give me a full procedure?

  • set up database
# Run postgresql v12
docker run --rm -d -p 35432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:12-alpine

# connect
psql -U postgres -h localhost -p 35432 -d postgres

# create kuq schema
CREATE SCHEMA kuq;

# create tables
CREATE TABLE kuq.tag (
	tag_key int4 NOT NULL,
	ctg_key int4 NULL,
	tag varchar(60) NULL,
	CONSTRAINT tag_pk PRIMARY KEY (tag_key),
	CONSTRAINT tag_un UNIQUE (tag_key)
);
CREATE INDEX tag_tag_idx ON kuq.tag USING btree (tag);
CREATE TABLE kuq.ctg (
	ctg_key int4 NOT NULL,
	CONSTRAINT ctg_pk PRIMARY KEY (ctg_key)
);
ALTER TABLE kuq.tag ADD CONSTRAINT tag_fk FOREIGN KEY (ctg_key) REFERENCES kuq.ctg(ctg_key);
  • run planter
planter 'postgres://postgres@localhost:35432/postgres?sslmode=disable' -s kuq -t 'tag' -t 'ctg' -o test.html
  • output
@startuml
hide circle
skinparam linetype ortho

entity "ctg" {
  + ctg_key:integer [PK]
  --
}

entity "tag" {
  + tag_key:integer [PK]
  --
  ctg_key:integer [FK]
  tag:character varying(60)
}

 tag }-- ctg
@enduml

It seems like it's not happening in current version, so I'll close this issue. Thanks!