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

All relations are duplicated #12

Closed
asitemade4u opened this issue Jan 24, 2020 · 3 comments
Closed

All relations are duplicated #12

asitemade4u opened this issue Jan 24, 2020 · 3 comments

Comments

@asitemade4u
Copy link

asitemade4u commented Jan 24, 2020

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

@hiroakis
Copy link
Contributor

@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

@achiku
Copy link
Owner

achiku commented May 18, 2021

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

@achiku achiku closed this as completed May 18, 2021
@kurotych
Copy link

kurotych commented Oct 31, 2022

Dirty fix minterest-finance@c8e10b3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants