Skip to content

Relationship column lists are null for dotted/mixed-case schemas #1147

Description

@hsusul

Bug

TABLE_RELATIONSHIPS_SQL / VIEWS_KEY_DEPENDENCIES_SQL filter some clauses with connamespace::regnamespace::text, while the outer table filter correctly uses nspname.

For schemas that need quoting, those differ:

nspname ::regnamespace::text
odd.schema "odd.schema"
MySchema "MySchema"

So IN ('odd.schema') matches nspname but misses regnamespace::text. The FK lateral still returns a row (aggregate), but with null columns / referenced_columns.

Impact

Typegen relationship inference (PostgresMetaRelationships) drops FK column info for projects that use dotted or mixed-case schema names.

Repro

create schema "odd.schema";
create table "odd.schema".parent (id int8 primary key);
create table "odd.schema".child (
  id int8 primary key,
  parent_id int8 references "odd.schema".parent (id)
);

Then relationships.list({ includedSchemas: ['odd.schema'] }) — relationship exists but columns / referenced_columns are null.

Expected

Filter by nspname (or oid via pg_namespace) consistently so column lists are populated.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions