Skip to content

feat: treat public names as unqualified and hide other schemas - #68

Merged
omer-cengel merged 1 commit into
masterfrom
feature/model-one-public-namespace
Oct 10, 2026
Merged

omer-cengel merged 1 commit into
masterfrom
feature/model-one-public-namespace

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

sqlcj now models exactly one PostgreSQL namespace. Unqualified and public-qualified table and type names — users, public.users, "public"."users" — are the same name, so pg_dump snapshots and migrations that qualify every object with public. load into the same model as unqualified ones, while tables and types of any other schema can no longer be silently mistaken for a modeled object of the same unqualified name.

Changes

  • Schema qualifiers are compared without SQL identifier delimiters and case-insensitively; search_path is not followed.
  • CREATE TABLE, ALTER TABLE, CREATE TYPE, and ALTER TYPE whose own table or type belongs to another schema are ignored before anything they name is resolved, whether the parser can read them or not; DROP TABLE skips such names and still drops modeled tables named beside them.
  • A LIKE or PARTITION OF source of another schema fails as Table not found in schema: <schema>.<t>; an ATTACH or DETACH PARTITION partition of another schema is ignored.
  • ALTER TABLE ... SET SCHEMA <schema> as the sole action removes the table, does nothing for public, and is rejected for a table with modeled partitions or when combined with another action.
  • public-qualified enum names resolve in CREATE TYPE (replacing a modeled enum of that name), ADD VALUE, RENAME VALUE, RENAME TO, column types, ADD COLUMN, ALTER COLUMN ... TYPE, and casts, including arrays written as public.mood[] or "public"."mood"[]; ALTER TYPE ... SET SCHEMA public of a modeled enum does nothing, and RENAME TO or SET SCHEMA of an unmodeled type is ignored however it is qualified.
  • Queries naming a table of another schema in FROM, JOIN, INSERT, UPDATE, or DELETE are rejected as Table not found in schema: <schema>.<t>.
  • PostgreSQL schema and query documentation describe the namespace rule and its tests.

Scope and non-goals

  • Schema-qualified column references and qualifier.* in queries are not supported.
  • A public partition attached to a table of another schema, pg_catalog-qualified names, and three-part names are not modeled.
  • An unreadable DROP TABLE keeps its existing handling.
  • ALTER TYPE ... SET SCHEMA of a modeled enum to a schema other than public stays rejected.
  • Generated code and the runtime are unchanged.

@omer-cengel
omer-cengel merged commit f4f9ab1 into master Oct 10, 2026
7 checks passed
@omer-cengel
omer-cengel deleted the feature/model-one-public-namespace branch October 10, 2026 19:09
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.

1 participant