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

doesn't draw relationship arrows with output from pg_dump 9.6.10... #10

Open
ale-dd opened this issue Feb 21, 2019 · 5 comments
Open

doesn't draw relationship arrows with output from pg_dump 9.6.10... #10

ale-dd opened this issue Feb 21, 2019 · 5 comments

Comments

@ale-dd
Copy link

ale-dd commented Feb 21, 2019

Unfortunately this seems not to draw relationship arrows with output from pg_dump 9.6.10...

@rm-hull
Copy link
Owner

rm-hull commented Feb 21, 2019

can you supply an example which does not work please?

@slavkoja
Copy link

slavkoja commented Jun 9, 2019

I have similar problem with missing edges, while not pg_dump, but SQLite schema:

CREATE TABLE domains (
    id          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    name        TEXT NOT NULL
);

CREATE TABLE users (
    id          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    domain_id   int(11) NOT NULL,
    name        varchar(100) NOT NULL,
    email       varchar(100) NOT NULL UNIQUE,
    password    varchar(150) NOT NULL,
    
    FOREIGN KEY (domain_id) REFERENCES domains(id) ON DELETE CASCADE
);

CREATE TABLE aliases (
    id          INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    alias       varchar(100) NOT NULL,
    domain_id   int(11) NOT NULL,
    user_id     int(11) NOT NULL,
    
    FOREIGN KEY (domain_id) REFERENCES domains(id) ON DELETE CASCADE,
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);

But the FOREIGN KEY definitions appears as another column in "table" and no edges between fields are at all:

/*
 * Graphviz of 'example3.sql', created 2019-06-09 15:45:04.550911
 * Generated from https://github.com/rm-hull/sql_graphviz
 */
digraph g { graph [ rankdir = "LR" ];

  "domains" [
    shape=none
    label=<
      <table border="0" cellspacing="0" cellborder="1">
        <tr><td bgcolor="lightblue2"><font face="Times-bold" point-size="20">domains</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="id"><font face="Times-bold">id</font>  <font color="#535353">INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="name"><font face="Times-bold">name</font>  <font color="#535353">TEXT NOT NULL</font></td></tr>
      </table>
    >];

  "users" [
    shape=none
    label=<
      <table border="0" cellspacing="0" cellborder="1">
        <tr><td bgcolor="lightblue2"><font face="Times-bold" point-size="20">users</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="id"><font face="Times-bold">id</font>  <font color="#535353">INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="domain_id"><font face="Times-bold">domain_id</font>  <font color="#535353">int (11) NOT NULL</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="name"><font face="Times-bold">name</font>  <font color="#535353">varchar (100) NOT NULL</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="email"><font face="Times-bold">email</font>  <font color="#535353">varchar (100) NOT NULL UNIQUE</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="password"><font face="Times-bold">password</font>  <font color="#535353">varchar (150) NOT NULL</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="FOREIGN"><font face="Times-bold">FOREIGN</font>  <font color="#535353">KEY (domain_id) REFERENCES domains (id) ON DELETE CASCADE</font></td></tr>
      </table>
    >];

  "aliases" [
    shape=none
    label=<
      <table border="0" cellspacing="0" cellborder="1">
        <tr><td bgcolor="lightblue2"><font face="Times-bold" point-size="20">aliases</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="id"><font face="Times-bold">id</font>  <font color="#535353">INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="alias"><font face="Times-bold">alias</font>  <font color="#535353">varchar (100) NOT NULL</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="domain_id"><font face="Times-bold">domain_id</font>  <font color="#535353">int (11) NOT NULL</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="user_id"><font face="Times-bold">user_id</font>  <font color="#535353">int (11) NOT NULL</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="FOREIGN"><font face="Times-bold">FOREIGN</font>  <font color="#535353">KEY (domain_id) REFERENCES domains (id) ON DELETE CASCADE</font></td></tr>
        <tr><td bgcolor="grey96" align="left" port="FOREIGN"><font face="Times-bold">FOREIGN</font>  <font color="#535353">KEY (user_id) REFERENCES users (id) ON DELETE CASCADE</font></td></tr>
      </table>
    >];
}

When i move FOREIGN KEY definition into column definition, the result is the same (no edges), and it definitions appears inside column's cell.

@mevol
Copy link

mevol commented Jul 12, 2019

Same problem here. Manually added the relationships between the tables at the bottom of the graph.dot file and now it works fine. The edges statement is missing before the last curly bracket.

e.g. a -> {b c d e}
b -> {f g h i}
where a is my table holding the primary keys for my samples and relates to tables b,c,d,e; b itself then provides primary keys for tables f,g,h,i.

@mike-kfed
Copy link

I had this problem with a postgres 10.12 dump, where it also has some other keywords in the sql dump not considered in the parser defs.
I simply added Optional(Literal("INITIALLY DEFERRED") to add_fkey_def and it was fine, might help somebody.

@r-re
Copy link

r-re commented Apr 10, 2021

I believe this issue in relation to sqlite is because sql_graphviz parses foreign keys via sql alter table add constraint syntax which is not supported by sqlite (https://www.sqlite.org/omitted.html)

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

6 participants