Skip to content

fix: preserve table coordinates across ERD renderers - #97

Open
DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/preserve-erd-table-identity
Open

DivyamTalwar wants to merge 1 commit into
pgrundev:mainfrom
DivyamTalwar:fix/preserve-erd-table-identity

Conversation

@DivyamTalwar

Copy link
Copy Markdown
Contributor

What and why

Closes #96.

Introspection read source and target schemas but discarded them from relationship endpoints. Renderers then keyed layout and edges by table name, conflating distinct relations. Preserve structured schema/table coordinates through introspection, ASCII layouts, relationship forests, HTML and Mermaid. Keep uniquely resolvable legacy names working and refuse ambiguous legacy endpoints.

Verification

Verified commit: c3de1bf87d289472533cd3fdbfc299a9eb47f984.

  • Base regressions demonstrate duplicate/incorrect table identities and relationship routing.
  • Complete affected ERD tests, committed-HEAD bash scripts/gate.sh, and go test -race ./... pass.
  • TestIntegrationIntrospectPreservesQualifiedTableIdentity passes without skips on disposable PostgreSQL 14, 16 and 18, covering same names, embedded dots, quoted/Unicode schemas, index ownership and cross-schema foreign keys.
  • Renderer tests cover deterministic ordering, aliases and missing or ambiguous endpoints.

Scope, risk and rollback

The change is internal to the ERD model and renderers; the versioned model.Context schema is unchanged. Complex/duplicate table names receive explicit labels and stable Mermaid identifiers. No browser visual validation is claimed. No dependencies or database migrations change. Revert this commit to restore the previous rendering.

Checklist

  • scripts/gate.sh passes on committed HEAD; full race suite passes.
  • Read-only, privacy and deterministic-finding invariants preserved.
  • No new finding or model.Context JSON field; catalog/model schema unchanged.

Bare relation names and dot-concatenated schema keys collide for ordinary
same-named cross-schema tables and valid identifiers containing periods.
Use structured table coordinates for catalog assembly, index attachment,
relationship resolution and every renderer. Keep display labels separate
from identity and retain compact Mermaid IDs when unambiguous.

Preserve source/target schema metadata on edges, use deterministic opaque
IDs for unsafe or colliding Mermaid names, and avoid parsing FK display
text as coordinates. Legacy unique-name edges remain compatible; ambiguous
legacy edges do not silently guess a schema.

Real renderer regressions fail on 9e41414 and the complete ERD race suite
passes 20 repetitions. Add a disposable catalog fixture whose cleanup is
limited to successfully created schemas. PostgreSQL/parser verification
is required before publishing. No dependency or collector SQL changes.
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

Successfully merging this pull request may close these issues.

ERD rendering conflates same-named tables across schemas

1 participant