You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(erd): PostgreSQL catalog misses keys for non-owner roles, composite FKs give wrong edges; read pg_catalog #1167
ErdCatalog reads PostgreSQL through information_schema (erd_catalog.dart). Three problems:
Read-only roles see no keys. Per the PostgreSQL docs, information_schema.table_constraints lists only constraints of tables the current user owns or has some privilege other than SELECT on, and constraint_column_usage only columns of tables owned by a currently enabled role. Connected as an application or read-only user (not the schema owner), the diagram shows tables without PK markers and without relations.
Composite foreign keys produce wrong edges. The FK query joins key_column_usage and constraint_column_usage on the constraint name only; for a 2-column FK (a, b) → (x, y) this yields 4 pairs (a→x, a→y, b→x, b→y) instead of 2.
Slow on large catalogs.information_schema views are much slower than pg_catalog on databases with thousands of tables.
Problem
ErdCatalogreads PostgreSQL throughinformation_schema(erd_catalog.dart). Three problems:information_schema.table_constraintslists only constraints of tables the current user owns or has some privilege other than SELECT on, andconstraint_column_usageonly columns of tables owned by a currently enabled role. Connected as an application or read-only user (not the schema owner), the diagram shows tables without PK markers and without relations.key_column_usageandconstraint_column_usageon the constraint name only; for a 2-column FK(a, b) → (x, y)this yields 4 pairs (a→x,a→y,b→x,b→y) instead of 2.information_schemaviews are much slower thanpg_catalogon databases with thousands of tables.Scope
pg_attribute+pg_class+pg_namespace(attnum > 0, not dropped,relkind IN ('r','p')), type viaformat_type, PK viapg_index/pg_constraint contype = 'p', nullability viaattnotnull(useful for feat(erd): nullability, optional/mandatory edge ends, edge tooltip #1156).pg_constraint contype = 'f'withunnest(conkey, confkey) WITH ORDINALITY, so composite keys pair column by column; referenced table with its schema (cross-schema FKs, refactor(erd): ErdSource per connection, schema-aware catalog, neighbourhood load #1147).key_column_usagehas one row per column pair there, expected correct) and add a test.Acceptance
SELECTon the tables sees PKs and FKs.