Menu

#882 Foreign key referencing table with uppercase character(s) breaks schema "ER Diagram" generation.

1.6
open
nobody
bug (193)
5 days ago
6 days ago
Anonymous
No

Originally created by: BrianFehrleCMD

Version tested: 1.4
PostgreSQL Version: PostgreSQL 17.10

It looks like when a foreign key is added to reference a table with an uppercase character in the name, the ER Diagram generation breaks.

To recreate:

Step 1: Create tables

CREATE TABLE public."Testtable" (
    id serial primary key,
    one text NOT NULL,
    two text NOT NULL
);


CREATE TABLE public.some_othertable (
    id text NOT NULL,
    other_id integer NOT NULL
);

Step 2: Test diagram.
In the program, navigate to the schema public, right click and select 'ER Diagram', it will generate a diagram with two tables.

Step 3: Create a foreign key:

ALTER TABLE ONLY public.some_othertable ADD CONSTRAINT ibrokeit FOREIGN KEY (other_id) REFERENCES public."Testtable"(id);

Step 4: Test Diagram again.
Generate the 'ER Diagram' again and it will error with something like:

Image

Log output:

[07/01/2026 19:03:42] ERROR [pid:3031965] [app.views.logging:15] [request_id:28] [JS Error] Error: Can not create edge `22116205-658d-4e55-a9c8-effc20083897` with nonexistant target `"Testtable"`
    at Ve (http://localhost:28409/static/dist/assets/ERDTab.DsN5xvgJ.js:3:12281)
    at Ie.restore (http://localhost:28409/static/dist/assets/ERDTab.DsN5xvgJ.js:13:28507)
    at new je (http://localhost:28409/static/dist/assets/ERDTab.DsN5xvgJ.js:13:25069)
    at Proxy.add (http://localhost:28409/static/dist/assets/ERDTab.DsN5xvgJ.js:13:32410)
    at Proxy.initGraph (http://localhost:28409/static/dist/assets/ERDTab.DsN5xvgJ.js:16:113270)
    at http://localhost:28409/static/dist/assets/ERDTab.DsN5xvgJ.js:16:112167
  • Brian

Related

Tickets: #883

Discussion

  • Anonymous

    Anonymous - 6 days ago

    Originally posted by: ChronicallyJD

    I've opened [#883] with a fix for this. Root cause: draw_graph() keyed ER Diagram nodes by the raw unquoted table name but built FK edges from quote_ident()-quoted names, so for names needing quotes the node id and edge target diverged and Cytoscape aborted rendering. The PR keys nodes by the quoted identifier, resolves FK endpoints by display-label fallback (also fixes SQLite + the is_fk/is_pk flags), and fixes an ERD-tab html_id regex that broke the layout run. Includes PostgreSQL and SQLite regression tests.

     

    Related

    Tickets: #883

  • Anonymous

    Anonymous - 5 days ago

    Originally posted by: eug3nix

    Hi.
    Thanks for the bug report. We are currently working on porting ER diagrams to another rendering engine and this issue will be addressed as a part of that rewrite. I will keep the the issue open to validate it later against the new implementation

     

Log in to post a comment.

Auth0 Logo