Skip to content

refactor(erd): ErdSource per connection, schema-aware catalog, neighbourhood load #1147

Description

@ZhuchkaTriplesix

Problem

The ER diagram (#1063, #1145) works only as a tab of the SQL workspace, and its data layer does not fit the table browser:

Scope

  • ErdSource: loadSchema({String? schema}) and loadNeighbourhood({required ErdTableRef table, int depth = 1}). Implementations for PostgreSQL, MySQL, SQLite on top of a query runner: the SQL workspace delegate for the Diagram tab, the table browser's own read-only session for the table view.
  • Schema-aware catalog: the schema / database is passed explicitly. ErdTable gets schema; a table outside the current schema is labelled schema.table (cards, Mermaid, SVG).
  • Neighbourhood: the foreign-key query filtered on the table (either side), repeated up to depth; then columns only for the tables found. Cycles and self references terminate.
  • Availability: the workspace knows whether a diagram source exists; extension SQL workspaces get no Diagram button until an extension can declare one.
  • ErdView takes an ErdSource instead of the delegate + dialect, plus an optional focusTable (accented card, viewport centred on it).

Acceptance

  • The Diagram tab behaves as today; test/features/erd/erd_test.dart passes (updated only for the schema qualifier).
  • PostgreSQL: a table in schema sales with a FK to public.customers: the neighbourhood contains both, qualified.
  • Unit tests for the neighbourhood with a fake runner: depth 1 and 2, a cycle, a self reference, a table without relations.
  • The extension SQL workspace has no Diagram button.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority / Parity & RefactoringcoreCore library logic and servicesenhancementNew feature or requestfrontendTheme parser epic label: frontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions