Skip to content

fix(namespaces): per-namespace typed resolution for sql.<ns>.<table> and orm.<ns>.<Model>#803

Open
SevInf wants to merge 24 commits into
mainfrom
explicit-namespace-slice2
Open

fix(namespaces): per-namespace typed resolution for sql.<ns>.<table> and orm.<ns>.<Model>#803
SevInf wants to merge 24 commits into
mainfrom
explicit-namespace-slice2

Conversation

@SevInf

@SevInf SevInf commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Fixes the namespaced DSL/ORM accessors dropping the namespace coordinate at the type level: when two namespaces declared the same bare table/model name with different fields, neither namespace’s unique fields were usable in queries (runtime worked, typechecks failed).

Root cause

The emitted contract carried per-namespace domain/storage blocks, but the DSL/ORM type machinery resolved field/column types through the flat, first-name-wins maps (ContractModelDefinitions/ModelsOf, UnboundTables-union, flat FieldOutputTypes). The facet types (Namespace<C,NsId>, OrmNamespace<C,_,NsId>) carried the coordinate but dropped it when delegating to TableProxy/Collection.

Approach (emitter-first)

Made the emitted output/input TypeMaps namespace-aware (FieldOutputTypes[ns][model][field]), mirroring how domain.namespaces is already emitted, then re-anchored every SQL resolution path onto the namespace coordinate. This keeps typeParam-refined outputs (Vector<N>, Char<N>) correct AND per-namespace, and makes the flat maps vestigial internally.

  • emitter / sql-contract: nest FieldOutputTypes/FieldInputTypes by namespace; all SQL fixtures regenerated.
  • relational-core / sql-builder / sql-orm-client: TableProxy/Collection carry a required NsId; column/field/model types resolve from domain.namespaces[NsId] + storage.namespaces[NsId] + nested FieldOutputTypes[NsId]. No internal resolution reads the flat map.
  • mongo: MongoModelsMap reads its sole (__unbound__) namespace; row resolution reconciled with the nested maps.
  • integration: the e2e test is un-cast against a committed two-namespace fixture, which surfaced (and fixed) three latent per-namespace ORM gaps (collision model lookup, updateCount, cross-namespace include).

Validation

Workspace typecheck 138/138; pnpm test:packages 10042 passed (0 type errors; the only failures are sandbox-environmental — mongo-memory-server binary fetch + CLI spawn timeouts); namespaced integration 2/2 (real DB, cross-namespace FK); pnpm fixtures:check clean; pnpm lint:deps clean. Two committed type-anchors + a two-namespace integration fixture prove per-namespace resolution; a consolidated review passed (one must-fix found + fixed: the last flat-map read on the non-facet branch).

Follow-ups (out of scope)

Retiring ContractModelDefinitions / the public Models export entirely (now internally vestigial). Spec + dispatch history under projects/explicit-namespace-dsl/specs/namespace-coordinate-typed-resolution.spec.md.

Summary by CodeRabbit

  • New Features

    • Multi-namespace support: qualified query/ORM surfaces for models/tables across schemas (e.g., public/auth).
  • Refactor

    • Generated contract/type outputs now nest model field maps by namespace (public / unbound), and core typings (TableProxy, TypeMaps, ORM/collection types) were made namespace-aware.
  • Tests

    • Added/updated integration and many type-level tests and fixtures for namespaced behavior.
  • Documentation

    • Upgrade guidance for migrating to namespace-scoped type maps.
  • Chores

    • .gitignore adjusted for generated test fixtures.

@SevInf SevInf requested a review from a team as a code owner June 10, 2026 16:40
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Generated contract field maps were restructured to be namespace-scoped (e.g., public, __unbound__, auth, storage); emitter, core TypeMaps, SQL relational builder, ORM client, Mongo helpers, examples, tests, and an integration fixture were updated to consume the new shapes.

Changes

Namespace-aware type maps and accessors

Layer / File(s) Summary
Field-map generation and core TypeMaps
packages/1-framework/3-tooling/emitter/src/domain-type-generation.ts, packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts, packages/2-sql/1-core/contract/src/types.ts
Emitter now generates namespace-keyed field maps and core TypeMaps defaults/guards were updated to expect namespace→model→field nesting.
Generated contract declarations (examples & packages)
examples/*/src/contract.d.ts, examples/*/migrations/**/end-contract.d.ts, packages/3-extensions/*/src/contract*.d.ts, packages/3-extensions/supabase/src/contract/contract.d.ts
Many generated contract.d.ts files were re-emitted so FieldOutputTypes/FieldInputTypes are nested under public, __unbound__, or other namespace keys.
Relational core: namespace-aware column typing
packages/2-sql/4-lanes/relational-core/src/types.ts, packages/2-sql/4-lanes/relational-core/test/compute-column-js-type-namespace.types.test-d.ts, packages/2-sql/9-family/test/compute-column-js-type.test-d.ts
ComputeColumnJsType and its tests now accept an explicit namespace id and resolve per-namespace emitter outputs before falling back to storage codec lookup.
SQL builder: NamespaceTable and TableProxy generics
packages/2-sql/4-lanes/sql-builder/src/types/db.ts, packages/2-sql/4-lanes/sql-builder/src/types/table-proxy.ts, packages/2-sql/4-lanes/sql-builder/src/runtime/table-proxy-impl.ts
Introduced NamespaceTable, threaded NsId through ContractToQC/TableProxy, and updated runtime generics and SQL facade typing.
SQL ORM client: namespace propagation
packages/3-extensions/sql-orm-client/src/types.ts, packages/3-extensions/sql-orm-client/src/collection.ts, packages/3-extensions/sql-orm-client/src/orm.ts
Collection/ORM client types now carry nsId through accessors, includes, create/update inputs, and relation typing; many tests added/adjusted.
Mongo family: unbound namespace helpers
packages/2-mongo-family/1-foundation/mongo-contract/src/contract-types.ts, packages/2-mongo-family/5-query-builders/orm/*
Added MongoUnboundFieldInputTypes/MongoUnboundFieldOutputTypes and updated query-builder/type-resolution to read fields from the __unbound__ coordinate.
Emitter tests & integration fixture
test/integration/package.json, .gitignore, test/integration/test/namespaced-accessors/**
A new namespaced-accessors fixture and prisma-next config were added, integration emit script updated to emit the fixture, and .gitignore updated to allow the fixture generated/ output.
Example consumer updates
examples/retail-store/src/data/*, test/integration/test/namespaced-accessors-e2e.integration.test.ts
App/test code that referenced flat field maps was updated to index into the emitted namespace wrappers (__unbound__/public), and the integration e2e test now uses generated fixture artifacts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • aqrln

Poem

🐰 I hopped through types with eager paws,
public, auth, and unbound I saw.
Contracts nested neat like carrots in rows,
Emitters and builders now all in tow.
Hooray — the rabbit maps the fields that grow!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch explicit-namespace-slice2

@SevInf SevInf force-pushed the explicit-namespace-slice2 branch from 8ae10f7 to 189b20d Compare June 10, 2026 17:09
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 155.12 KB (0%)
postgres / emit 122.41 KB (0%)
mongo / no-emit 76.92 KB (0%)
mongo / emit 71.01 KB (0%)
cf-worker / no-emit 183.82 KB (0%)
cf-worker / emit 147.7 KB (0%)

@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/@prisma-next/extension-author-tools@803

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/@prisma-next/mongo-runtime@803

@prisma-next/family-mongo

npm i https://pkg.pr.new/@prisma-next/family-mongo@803

@prisma-next/sql-runtime

npm i https://pkg.pr.new/@prisma-next/sql-runtime@803

@prisma-next/family-sql

npm i https://pkg.pr.new/@prisma-next/family-sql@803

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/@prisma-next/extension-arktype-json@803

@prisma-next/middleware-cache

npm i https://pkg.pr.new/@prisma-next/middleware-cache@803

@prisma-next/mongo

npm i https://pkg.pr.new/@prisma-next/mongo@803

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/@prisma-next/extension-paradedb@803

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/@prisma-next/extension-pgvector@803

@prisma-next/extension-postgis

npm i https://pkg.pr.new/@prisma-next/extension-postgis@803

@prisma-next/postgres

npm i https://pkg.pr.new/@prisma-next/postgres@803

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/@prisma-next/sql-orm-client@803

@prisma-next/sqlite

npm i https://pkg.pr.new/@prisma-next/sqlite@803

@prisma-next/extension-supabase

npm i https://pkg.pr.new/@prisma-next/extension-supabase@803

@prisma-next/target-mongo

npm i https://pkg.pr.new/@prisma-next/target-mongo@803

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/@prisma-next/adapter-mongo@803

@prisma-next/driver-mongo

npm i https://pkg.pr.new/@prisma-next/driver-mongo@803

@prisma-next/contract

npm i https://pkg.pr.new/@prisma-next/contract@803

@prisma-next/utils

npm i https://pkg.pr.new/@prisma-next/utils@803

@prisma-next/config

npm i https://pkg.pr.new/@prisma-next/config@803

@prisma-next/errors

npm i https://pkg.pr.new/@prisma-next/errors@803

@prisma-next/framework-components

npm i https://pkg.pr.new/@prisma-next/framework-components@803

@prisma-next/operations

npm i https://pkg.pr.new/@prisma-next/operations@803

@prisma-next/ts-render

npm i https://pkg.pr.new/@prisma-next/ts-render@803

@prisma-next/contract-authoring

npm i https://pkg.pr.new/@prisma-next/contract-authoring@803

@prisma-next/ids

npm i https://pkg.pr.new/@prisma-next/ids@803

@prisma-next/psl-parser

npm i https://pkg.pr.new/@prisma-next/psl-parser@803

@prisma-next/psl-printer

npm i https://pkg.pr.new/@prisma-next/psl-printer@803

@prisma-next/cli

npm i https://pkg.pr.new/@prisma-next/cli@803

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/@prisma-next/cli-telemetry@803

@prisma-next/emitter

npm i https://pkg.pr.new/@prisma-next/emitter@803

@prisma-next/migration-tools

npm i https://pkg.pr.new/@prisma-next/migration-tools@803

prisma-next

npm i https://pkg.pr.new/prisma-next@803

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/@prisma-next/vite-plugin-contract-emit@803

@prisma-next/mongo-codec

npm i https://pkg.pr.new/@prisma-next/mongo-codec@803

@prisma-next/mongo-contract

npm i https://pkg.pr.new/@prisma-next/mongo-contract@803

@prisma-next/mongo-value

npm i https://pkg.pr.new/@prisma-next/mongo-value@803

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/@prisma-next/mongo-contract-psl@803

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/@prisma-next/mongo-contract-ts@803

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/@prisma-next/mongo-emitter@803

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/@prisma-next/mongo-schema-ir@803

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/@prisma-next/mongo-query-ast@803

@prisma-next/mongo-orm

npm i https://pkg.pr.new/@prisma-next/mongo-orm@803

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/@prisma-next/mongo-query-builder@803

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/@prisma-next/mongo-lowering@803

@prisma-next/mongo-wire

npm i https://pkg.pr.new/@prisma-next/mongo-wire@803

@prisma-next/sql-contract

npm i https://pkg.pr.new/@prisma-next/sql-contract@803

@prisma-next/sql-errors

npm i https://pkg.pr.new/@prisma-next/sql-errors@803

@prisma-next/sql-operations

npm i https://pkg.pr.new/@prisma-next/sql-operations@803

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/@prisma-next/sql-schema-ir@803

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/@prisma-next/sql-contract-psl@803

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/@prisma-next/sql-contract-ts@803

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/@prisma-next/sql-contract-emitter@803

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/@prisma-next/sql-lane-query-builder@803

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/@prisma-next/sql-relational-core@803

@prisma-next/sql-builder

npm i https://pkg.pr.new/@prisma-next/sql-builder@803

@prisma-next/target-postgres

npm i https://pkg.pr.new/@prisma-next/target-postgres@803

@prisma-next/target-sqlite

npm i https://pkg.pr.new/@prisma-next/target-sqlite@803

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/@prisma-next/adapter-postgres@803

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/@prisma-next/adapter-sqlite@803

@prisma-next/driver-postgres

npm i https://pkg.pr.new/@prisma-next/driver-postgres@803

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/@prisma-next/driver-sqlite@803

commit: dffb594


test('the public-namespace users facet can select its unique column `email`', () => {
const row = db.public.users.select('id', 'email').build();
expectTypeOf(row).not.toBeNever();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use specific type here

@SevInf SevInf force-pushed the explicit-namespace-slice2 branch 2 times, most recently from 66fab18 to dfce81a Compare June 12, 2026 10:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md`:
- Around line 245-266: Remove the transient ticket/PR identifiers from the
upgrade guide text (specifically remove references to "TML-2886", "TML-2550",
and "PR `#813`") and replace them with stable, descriptive phrasing such as
"internal change: typed ALTER TABLE behavior" or "internal change: per-namespace
typed resolution"; add a short parenthetical saying "see changelog/release notes
for ticket/PR links" so readers can find details, and move the actual IDs and
links into the changelog or release notes instead of keeping them in
instructions.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: f9e93313-9bf7-4647-88e1-90b9d8ba8158

📥 Commits

Reviewing files that changed from the base of the PR and between 66fab18 and dfce81a.

⛔ Files ignored due to path filters (12)
  • examples/bundle-size/src/mongo/generated/contract.d.ts is excluded by !**/generated/**
  • examples/bundle-size/src/postgres/generated/contract.d.ts is excluded by !**/generated/**
  • packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/e2e/framework/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/e2e/framework/test/sqlite/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/mongo/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/namespaced-accessors/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/namespaced-accessors/fixtures/generated/contract.json is excluded by !**/generated/**
  • test/integration/test/sql-builder/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/sql-orm-client/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/sql-orm-client/fixtures/polymorphism/generated/contract.d.ts is excluded by !**/generated/**
📒 Files selected for processing (82)
  • .gitignore
  • apps/telemetry-backend/src/prisma/contract.d.ts
  • examples/mongo-blog-leaderboard/src/contract.d.ts
  • examples/mongo-demo/migrations/app/20260409T1030_migration/end-contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/end-contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/start-contract.d.ts
  • examples/mongo-demo/src/contract.d.ts
  • examples/multi-extension-monorepo/app/src/contract.d.ts
  • examples/multi-extension-monorepo/packages/audit/src/contract.d.ts
  • examples/multi-extension-monorepo/packages/feature-flags/src/contract.d.ts
  • examples/paradedb-demo/src/prisma/contract.d.ts
  • examples/prisma-next-cloudflare-worker/src/prisma/contract.d.ts
  • examples/prisma-next-demo-sqlite/src/prisma/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/start-contract.d.ts
  • examples/prisma-next-demo/src/prisma/contract.d.ts
  • examples/prisma-next-demo/test/demo-dx.types.test.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/end-contract.d.ts
  • examples/prisma-next-postgis-demo/src/prisma/contract.d.ts
  • examples/react-router-demo/src/prisma/contract.d.ts
  • examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
  • examples/retail-store/src/contract.d.ts
  • examples/retail-store/src/data/events.ts
  • examples/retail-store/src/data/products.ts
  • examples/retail-store/src/data/users.ts
  • examples/supabase/src/contract.d.ts
  • packages/1-framework/3-tooling/emitter/src/domain-type-generation.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
  • packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/contract-types.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/exports/index.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/contract-types.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/fixtures/orm-contract.d.ts
  • packages/2-mongo-family/5-query-builders/orm/src/field-accessor.ts
  • packages/2-mongo-family/5-query-builders/orm/src/types.ts
  • packages/2-sql/1-core/contract/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.factory-form.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.field-output.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/4-lanes/relational-core/test/compute-column-js-type-namespace.types.test-d.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/table-proxy-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/db.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/table-proxy.ts
  • packages/2-sql/4-lanes/sql-builder/test/enum-type.field-output.test-d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespace-unique-fields.types.test-d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespaced-db.types.test-d.ts
  • packages/2-sql/9-family/test/compute-column-js-type.test-d.ts
  • packages/3-extensions/paradedb/src/contract.d.ts
  • packages/3-extensions/pgvector/src/contract.d.ts
  • packages/3-extensions/postgis/src/contract.d.ts
  • packages/3-extensions/postgres/test/namespaced-facade.types.test-d.ts
  • packages/3-extensions/sql-orm-client/src/collection-internal-types.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/orm.ts
  • packages/3-extensions/sql-orm-client/src/types.ts
  • packages/3-extensions/sql-orm-client/test/annotations.types.test-d.ts
  • packages/3-extensions/sql-orm-client/test/enum-type.field-output.test-d.ts
  • packages/3-extensions/sql-orm-client/test/generated-contract-types.test-d.ts
  • packages/3-extensions/sql-orm-client/test/orm-namespace-unique-fields.types.test-d.ts
  • packages/3-extensions/sqlite/test/namespaced-facade.types.test-d.ts
  • packages/3-extensions/supabase/src/contract/contract.d.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.13-to-0.14/instructions.md
  • skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md
  • test/integration/package.json
  • test/integration/test/fixtures/contract.d.ts
  • test/integration/test/namespaced-accessors-e2e.integration.test.ts
  • test/integration/test/namespaced-accessors/fixtures/contract.ts
  • test/integration/test/namespaced-accessors/fixtures/prisma-next.config.ts
✅ Files skipped from review due to trivial changes (14)
  • packages/3-extensions/pgvector/src/contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/start-contract.d.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/end-contract.d.ts
  • examples/mongo-demo/src/contract.d.ts
  • packages/3-extensions/postgres/test/namespaced-facade.types.test-d.ts
  • examples/retail-store/src/contract.d.ts
  • examples/prisma-next-demo-sqlite/src/prisma/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • test/integration/test/fixtures/contract.d.ts
  • examples/mongo-blog-leaderboard/src/contract.d.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.13-to-0.14/instructions.md
  • examples/multi-extension-monorepo/packages/feature-flags/src/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.d.ts
  • examples/paradedb-demo/src/prisma/contract.d.ts
🚧 Files skipped from review as they are similar to previous changes (62)
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.factory-form.test.ts
  • test/integration/test/namespaced-accessors/fixtures/prisma-next.config.ts
  • examples/prisma-next-postgis-demo/src/prisma/contract.d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/exports/index.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
  • examples/retail-store/src/data/users.ts
  • examples/mongo-demo/migrations/app/20260409T1030_migration/end-contract.d.ts
  • packages/3-extensions/postgis/src/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • packages/3-extensions/sql-orm-client/test/annotations.types.test-d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/end-contract.d.ts
  • packages/3-extensions/sql-orm-client/src/collection-internal-types.ts
  • packages/1-framework/3-tooling/emitter/src/domain-type-generation.ts
  • test/integration/package.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
  • apps/telemetry-backend/src/prisma/contract.d.ts
  • examples/multi-extension-monorepo/app/src/contract.d.ts
  • packages/3-extensions/sql-orm-client/src/orm.ts
  • examples/retail-store/src/data/products.ts
  • packages/2-mongo-family/5-query-builders/orm/src/types.ts
  • examples/prisma-next-cloudflare-worker/src/prisma/contract.d.ts
  • packages/3-extensions/paradedb/src/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/end-contract.d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespaced-db.types.test-d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/end-contract.d.ts
  • packages/2-sql/4-lanes/sql-builder/test/enum-type.field-output.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/contract-types.test-d.ts
  • .gitignore
  • examples/prisma-next-demo/test/demo-dx.types.test.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/start-contract.d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/fixtures/orm-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-types.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/start-contract.d.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
  • examples/prisma-next-demo/src/prisma/contract.d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespace-unique-fields.types.test-d.ts
  • examples/multi-extension-monorepo/packages/audit/src/contract.d.ts
  • examples/react-router-demo/src/prisma/contract.d.ts
  • packages/2-mongo-family/5-query-builders/orm/src/field-accessor.ts
  • packages/3-extensions/supabase/src/contract/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/start-contract.d.ts
  • packages/2-sql/1-core/contract/src/types.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/db.ts
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.field-output.test.ts
  • packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
  • examples/supabase/src/contract.d.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • packages/3-extensions/sql-orm-client/test/orm-namespace-unique-fields.types.test-d.ts
  • examples/retail-store/src/data/events.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/table-proxy-impl.ts
  • test/integration/test/namespaced-accessors-e2e.integration.test.ts
  • packages/2-sql/4-lanes/relational-core/test/compute-column-js-type-namespace.types.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/contract-types.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/table-proxy.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/types.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md`:
- Around line 245-266: Remove the transient ticket/PR identifiers from the
upgrade guide text (specifically remove references to "TML-2886", "TML-2550",
and "PR `#813`") and replace them with stable, descriptive phrasing such as
"internal change: typed ALTER TABLE behavior" or "internal change: per-namespace
typed resolution"; add a short parenthetical saying "see changelog/release notes
for ticket/PR links" so readers can find details, and move the actual IDs and
links into the changelog or release notes instead of keeping them in
instructions.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: f9e93313-9bf7-4647-88e1-90b9d8ba8158

📥 Commits

Reviewing files that changed from the base of the PR and between 66fab18 and dfce81a.

⛔ Files ignored due to path filters (12)
  • examples/bundle-size/src/mongo/generated/contract.d.ts is excluded by !**/generated/**
  • examples/bundle-size/src/postgres/generated/contract.d.ts is excluded by !**/generated/**
  • packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • packages/3-extensions/sql-orm-client/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/e2e/framework/test/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/e2e/framework/test/sqlite/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/mongo/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/namespaced-accessors/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/namespaced-accessors/fixtures/generated/contract.json is excluded by !**/generated/**
  • test/integration/test/sql-builder/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/sql-orm-client/fixtures/generated/contract.d.ts is excluded by !**/generated/**
  • test/integration/test/sql-orm-client/fixtures/polymorphism/generated/contract.d.ts is excluded by !**/generated/**
📒 Files selected for processing (82)
  • .gitignore
  • apps/telemetry-backend/src/prisma/contract.d.ts
  • examples/mongo-blog-leaderboard/src/contract.d.ts
  • examples/mongo-demo/migrations/app/20260409T1030_migration/end-contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/end-contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/start-contract.d.ts
  • examples/mongo-demo/src/contract.d.ts
  • examples/multi-extension-monorepo/app/src/contract.d.ts
  • examples/multi-extension-monorepo/packages/audit/src/contract.d.ts
  • examples/multi-extension-monorepo/packages/feature-flags/src/contract.d.ts
  • examples/paradedb-demo/src/prisma/contract.d.ts
  • examples/prisma-next-cloudflare-worker/src/prisma/contract.d.ts
  • examples/prisma-next-demo-sqlite/src/prisma/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/start-contract.d.ts
  • examples/prisma-next-demo/src/prisma/contract.d.ts
  • examples/prisma-next-demo/test/demo-dx.types.test.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/end-contract.d.ts
  • examples/prisma-next-postgis-demo/src/prisma/contract.d.ts
  • examples/react-router-demo/src/prisma/contract.d.ts
  • examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
  • examples/retail-store/src/contract.d.ts
  • examples/retail-store/src/data/events.ts
  • examples/retail-store/src/data/products.ts
  • examples/retail-store/src/data/users.ts
  • examples/supabase/src/contract.d.ts
  • packages/1-framework/3-tooling/emitter/src/domain-type-generation.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
  • packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/contract-types.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/exports/index.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/contract-types.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/fixtures/orm-contract.d.ts
  • packages/2-mongo-family/5-query-builders/orm/src/field-accessor.ts
  • packages/2-mongo-family/5-query-builders/orm/src/types.ts
  • packages/2-sql/1-core/contract/src/types.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-types.ts
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.factory-form.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.field-output.test.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/4-lanes/relational-core/test/compute-column-js-type-namespace.types.test-d.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/table-proxy-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/db.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/table-proxy.ts
  • packages/2-sql/4-lanes/sql-builder/test/enum-type.field-output.test-d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespace-unique-fields.types.test-d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespaced-db.types.test-d.ts
  • packages/2-sql/9-family/test/compute-column-js-type.test-d.ts
  • packages/3-extensions/paradedb/src/contract.d.ts
  • packages/3-extensions/pgvector/src/contract.d.ts
  • packages/3-extensions/postgis/src/contract.d.ts
  • packages/3-extensions/postgres/test/namespaced-facade.types.test-d.ts
  • packages/3-extensions/sql-orm-client/src/collection-internal-types.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/orm.ts
  • packages/3-extensions/sql-orm-client/src/types.ts
  • packages/3-extensions/sql-orm-client/test/annotations.types.test-d.ts
  • packages/3-extensions/sql-orm-client/test/enum-type.field-output.test-d.ts
  • packages/3-extensions/sql-orm-client/test/generated-contract-types.test-d.ts
  • packages/3-extensions/sql-orm-client/test/orm-namespace-unique-fields.types.test-d.ts
  • packages/3-extensions/sqlite/test/namespaced-facade.types.test-d.ts
  • packages/3-extensions/supabase/src/contract/contract.d.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.13-to-0.14/instructions.md
  • skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md
  • test/integration/package.json
  • test/integration/test/fixtures/contract.d.ts
  • test/integration/test/namespaced-accessors-e2e.integration.test.ts
  • test/integration/test/namespaced-accessors/fixtures/contract.ts
  • test/integration/test/namespaced-accessors/fixtures/prisma-next.config.ts
✅ Files skipped from review due to trivial changes (14)
  • packages/3-extensions/pgvector/src/contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/start-contract.d.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/end-contract.d.ts
  • examples/mongo-demo/src/contract.d.ts
  • packages/3-extensions/postgres/test/namespaced-facade.types.test-d.ts
  • examples/retail-store/src/contract.d.ts
  • examples/prisma-next-demo-sqlite/src/prisma/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • test/integration/test/fixtures/contract.d.ts
  • examples/mongo-blog-leaderboard/src/contract.d.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.13-to-0.14/instructions.md
  • examples/multi-extension-monorepo/packages/feature-flags/src/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.d.ts
  • examples/paradedb-demo/src/prisma/contract.d.ts
🚧 Files skipped from review as they are similar to previous changes (62)
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.factory-form.test.ts
  • test/integration/test/namespaced-accessors/fixtures/prisma-next.config.ts
  • examples/prisma-next-postgis-demo/src/prisma/contract.d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/exports/index.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
  • examples/retail-store/src/data/users.ts
  • examples/mongo-demo/migrations/app/20260409T1030_migration/end-contract.d.ts
  • packages/3-extensions/postgis/src/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • packages/3-extensions/sql-orm-client/test/annotations.types.test-d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/end-contract.d.ts
  • packages/3-extensions/sql-orm-client/src/collection-internal-types.ts
  • packages/1-framework/3-tooling/emitter/src/domain-type-generation.ts
  • test/integration/package.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
  • apps/telemetry-backend/src/prisma/contract.d.ts
  • examples/multi-extension-monorepo/app/src/contract.d.ts
  • packages/3-extensions/sql-orm-client/src/orm.ts
  • examples/retail-store/src/data/products.ts
  • packages/2-mongo-family/5-query-builders/orm/src/types.ts
  • examples/prisma-next-cloudflare-worker/src/prisma/contract.d.ts
  • packages/3-extensions/paradedb/src/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/end-contract.d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespaced-db.types.test-d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/end-contract.d.ts
  • packages/2-sql/4-lanes/sql-builder/test/enum-type.field-output.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/contract-types.test-d.ts
  • .gitignore
  • examples/prisma-next-demo/test/demo-dx.types.test.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/start-contract.d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/fixtures/orm-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
  • packages/2-sql/2-authoring/contract-ts/src/contract-types.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/start-contract.d.ts
  • packages/1-framework/3-tooling/emitter/src/generate-contract-dts.ts
  • examples/prisma-next-demo/src/prisma/contract.d.ts
  • packages/2-sql/4-lanes/sql-builder/test/types/namespace-unique-fields.types.test-d.ts
  • examples/multi-extension-monorepo/packages/audit/src/contract.d.ts
  • examples/react-router-demo/src/prisma/contract.d.ts
  • packages/2-mongo-family/5-query-builders/orm/src/field-accessor.ts
  • packages/3-extensions/supabase/src/contract/contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/start-contract.d.ts
  • packages/2-sql/1-core/contract/src/types.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/db.ts
  • packages/2-sql/2-authoring/contract-ts/test/enum-type.field-output.test.ts
  • packages/1-framework/3-tooling/emitter/test/generate-contract-dts.multi-namespace.test.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
  • examples/supabase/src/contract.d.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • packages/3-extensions/sql-orm-client/test/orm-namespace-unique-fields.types.test-d.ts
  • examples/retail-store/src/data/events.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/table-proxy-impl.ts
  • test/integration/test/namespaced-accessors-e2e.integration.test.ts
  • packages/2-sql/4-lanes/relational-core/test/compute-column-js-type-namespace.types.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/contract-types.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/table-proxy.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/types.ts
🛑 Comments failed to post (1)
skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md (1)

245-266: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid transient ticket IDs in the upgrade guide.

This note embeds TML-2550 and PR #813`` in durable docs, which will age poorly. Keep the stable upgrade guidance here and move ticket/PR references to changelog or release notes.

Based on learnings: durable docs should not reference transient project artifacts.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md`
around lines 245 - 266, Remove the transient ticket/PR identifiers from the
upgrade guide text (specifically remove references to "TML-2886", "TML-2550",
and "PR `#813`") and replace them with stable, descriptive phrasing such as
"internal change: typed ALTER TABLE behavior" or "internal change: per-namespace
typed resolution"; add a short parenthetical saying "see changelog/release notes
for ticket/PR links" so readers can find details, and move the actual IDs and
links into the changelog or release notes instead of keeping them in
instructions.md.

Source: Learnings

SevInf added 20 commits June 12, 2026 15:22
…inate

ExtractTableToModel, ExtractColumnToField, and ComputeColumnJsType now
take a required namespace coordinate and resolve table->model->column
within the per-namespace domain and storage blocks
(domain.namespaces[NsId].models, storage.namespaces[NsId].entries.table)
instead of scanning the flat cross-namespace model map. The output JS
type is derived from the per-namespace storage column codecId via
CodecTypes, so a bare table name shared across namespaces resolves to
each namespace own column rather than the per-namespace intersection.

Adds a type-test proving a two-namespace contract whose same bare table
name carries different columns per namespace resolves each namespace own
column type, and never for a column absent in that namespace.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
The refined (typeParam-applied) output/input field types previously lived
only in a flat, first-name-wins {model: {field}} map, so per-namespace
resolution either lost the refinement or collapsed same-named models across
namespaces. Nest the emitted FieldOutputTypes/FieldInputTypes by namespace
coordinate ({ns: {model: {field}}}), mirroring how domain.namespaces[ns] is
already emitted and reusing the existing per-model renderOutputTypeFor
refinement, so a parameterized column keeps its refined type (e.g. Vector<N>,
Char<36>) under its own namespace.

- emitter: add generateFieldTypesMapsByNamespace wrapping the per-model
  builder per namespace; wire it into generate-contract-dts.
- sql-contract: TypeMaps / FieldOutputTypesOf / FieldInputTypesOf accept the
  three-level nested shape.
- Regenerate all emitted contract.d.ts fixtures to the nested baseline. Only
  the .d.ts type shape changes; contract.json data and hashes are unchanged.

Mongo is single-namespace and nests harmlessly under __unbound__; its row
inference reads ContractModelDefinitions + codecs, not these maps, and its
two-level MongoTypeMaps constraint still accepts the nested shape.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…ce-nested FieldOutputTypes

ComputeColumnJsType now resolves a column to its refined JS output via the
emitter-emitted namespace-nested FieldOutputTypes[NsId][Model][Field] map,
keyed by the required namespace coordinate, replacing the interim codec-base
path. The table->model and column->field mapping is resolved per-namespace
from domain.namespaces[NsId].models; a storage column not backed by a model
field falls back to a codec-output lookup, and a column absent in the
namespace resolves to never.

This preserves parameterized codec refinements (e.g. Vector<N>, Char<N>) that
the codec-base path dropped, while keeping same-bare-table-name collisions
resolving each namespace own field.

- relational-core type-test: assert a parameterized column keeps its refined
  type per-namespace (not the bare codec output) and the collision resolves
  each namespace own field.
- family-sql direct test: rework to the namespace-aware signature with refined
  expectations plus a codec-fallback case.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
TableProxy now carries a required namespace-coordinate type parameter
(TableProxy<C, NsId, Name>); Namespace<C, NsId> threads NsId into each
table proxy. The proxy derives its selectable columns (scope) from the
exact per-namespace storage table
(storage.namespaces[NsId].entries.table[Name]) rather than the
cross-namespace UnboundTables union, and its column output/input types
from the namespace coordinate via ComputeColumnJsType /
FieldOutputTypes[NsId] / FieldInputTypes[NsId] / domain.namespaces[NsId].

So a bare table name shared across namespaces resolves to each
namespace own columns: each namespace unique column is selectable
through its own facet, and the other namespace unique column is not.
UnboundTables / TableInAnyNamespace remain defined for other consumers;
only the facet column resolution stops depending on them. The runtime
TableProxyImpl implements TableProxy<C, string, Name, ...> (namespace
coordinate erased at runtime, already threaded as namespaceId).

- commit the now-green namespace-unique-fields anchor type-test.
- update namespaced-db type-test to the coordinate-keyed signature.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
… coordinate

The OrmNamespace mapping threads the namespace coordinate into the row of
each model collection: ModelCollection resolves InferRootRow at the
namespace coordinate, so a bare model name shared across namespaces
resolves each namespace its own fields (the per-namespace
domain.namespaces[NsId] block + the nested FieldOutputTypes[NsId] map)
rather than the flat first-name-wins ContractModelDefinitions map.

The resolution chain in types.ts (ModelDef / FieldsOf / ModelTableName /
FieldColumnName / NamespaceTableDef / ResolvedStorageColumn / FieldJsType /
DefaultModelRow / InferRootRow + where/numeric helpers) now takes an
optional namespace coordinate (defaulting to the model storage own
namespace via ResolvedNsId), and the read row resolves its field types
directly from the emitter nested FieldOutputTypes[ns][model][field] map
(carrying value objects + refined codecs + nullability), falling back to
the codec path for fields absent from that map. This also fixes
FieldStorageJsType, which called the pre-coordinate ComputeColumnJsType
signature.

- commit the now-green orm-namespace-unique-fields anchor type-test.
- nest the manual FieldOutputTypes fixtures in generated-contract-types to
  the namespace-keyed shape the emitter now emits.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…-namespace

Thread the namespace coordinate carried on CollectionTypeState.nsId through
the create/update/where input helpers so a model reached via orm.<ns>.<Model>
resolves its fields within its own namespace, matching the read row. Under a
same-bare-model-name collision each namespace facet now accepts its own
fields and rejects the other namespace's, instead of the flat first-name-wins
ModelsOf map governing input resolution.

A directly-constructed collection keeps nsId: never, so single-namespace
input shapes are unchanged.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…nd namespace

Re-point MongoModelsMap at the contract's sole domain namespace
(domain.namespaces[UNBOUND_NAMESPACE_ID].models) via the framework sentinel,
and route RootModelName and InferModelRow through it so no Mongo type reads
the flat ContractModelDefinitions union directly.

Reconcile the D1 emitter change that nests FieldOutputTypes/FieldInputTypes by
namespace id: add MongoUnboundFieldOutputTypes/MongoUnboundFieldInputTypes,
which read the per-model refined map under UNBOUND_NAMESPACE_ID (falling back
to a pre-nesting flat map). ResolvedModelRow, ResolvedOutputRow and
ResolvedInputRow consume these so a Mongo refined row (including any
parameterized field) no longer silently degrades to the codec fallback when the
emitted map is namespace-nested. Inferred row types are unchanged.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
D1 nested the emitted FieldOutputTypes/FieldInputTypes by namespace and
regenerated the SQL + example contract.d.ts, but missed this mongo test
fixture. Re-emit it via the orm-fixture generator so its TypeMaps match the
current emitter (per-model maps now nested under __unbound__).

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…pe helpers

With the mongo fixture now on the nested TypeMaps shape, every emitted contract
nests its field-type maps by namespace, so the pre-nesting flat-map fallback in
MongoUnboundFieldOutputTypes/MongoUnboundFieldInputTypes is unreachable. Resolve
to never (read by the row resolvers as no refined map -> codec fallback) instead
of reading a flat map. Drop the now-obsolete flat back-compat type-test.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
The framework TypeMaps FieldOutputTypes/FieldInputTypes slots are nested by
namespace id (Record<string, Record<string, Record<string, unknown>>>), but the
SQL TS-authoring contract type still produced a flat model->field map, so
SqlContractResult no longer satisfied the constraint. Nest the per-model map
under the target default storage namespace (matching how BuiltStorage lumps
every model under that coordinate).

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
TableProxy gained a leading NsId type parameter, and the emitted
FieldInputTypes/FieldOutputTypes are now nested by namespace id. Update the
postgres/sqlite namespaced-facade type-tests to the TableProxy<C, NsId, Name>
arity, and index the retail-store example data helpers through the unbound
namespace coordinate.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
Author (via buildSqlContractFromDefinition) and emit a same-bare-table-name
two-namespace contract: public.users {id,email} + auth.users {id,token} with a
cross-namespace FK public.profile.user_id -> auth.users.id and a public.Profile
.user relation to auth.User. Emitting it to a committed contract.json +
contract.d.ts gives the namespaced-accessors integration test a precise
per-namespace Contract type to type-check against. Wired into the package emit
so fixtures:check re-emits it deterministically.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
Un-ignore namespaced-accessors/fixtures/generated (mirroring the mongo fixture
exception) and commit the emitted contract.json + contract.d.ts so the
namespaced-accessors integration test type-checks against the precise
per-namespace Contract and fixtures:check can detect drift.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…s + relations

Un-casting the namespaced e2e test surfaced three facet-resolution gaps the
runtime-view casts had hidden:

- CollectionModelName read the flat ModelsOf map, which keys a cross-namespace
  union to its shared names and dropped a model unique to one namespace
  (e.g. public.Profile) under a same-bare-name collision. Read the union of
  every namespace block.
- updateCount did not thread State[nsId] into its DefaultModelRow, so a facet
  collections updateCount resolved the flat (collision-collapsed) row.
- The relation/include chain (ModelRelations -> RelationsOf -> RelationNames /
  RelatedModelName / RelationCardinality / IsToManyRelation / IncludeRelationValue)
  read flat ModelDef, so a facet could not name its relations, and a
  cross-namespace include resolved the related row at the parent namespace.
  Thread an additive NsId coordinate (default never preserves the non-facet
  shape) and resolve the included row at the relations target namespace via a
  new RelationTargetNamespace.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
… Contract

Drive postgres<Contract>({ contractJson }) from the committed two-namespace
fixture and drop the blindCast SqlView/OrmView/LoweredAdapter views. db.sql and
db.orm are now precisely typed per-namespace: public.users exposes email and
auth.users exposes token (and the reverse is a compile error, asserted with
ts-expect-error), and the cross-namespace Profile.user include resolves the
auth.User row. Runtime assertions are unchanged.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…n (F1)

The no-coordinate (NsId = never) branch of ModelDef, AllModelRelationEntries,
and the VariantRow/VariantModelRow model-name guards still read the flat
ContractModelDefinitions / ModelsOf map, a reachable path that violated the
required-coordinate invariant. Resolve those by scanning every
domain.namespaces[ns].models block instead (the same flat-map-free scan used by
CollectionModelName): for a single-namespace contract the scan of the sole
namespace is byte-for-byte identical to the old flat read. Remove the ModelsOf
alias and the ContractModelDefinitions import so no internal resolver reads the
flat map.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
Mains enum work (#769) renders enum value unions into the field-type maps;
our slice nests those maps by namespace id. Reconcile the enum type-tests to
the nested shape: index ExtractFieldOutputTypes/InputTypes through the default
namespace (public) or the fixtures __unbound__ coordinate, and pass the NsId
coordinate to ContractToQC. Enum value unions still resolve per-namespace; no
flat-map read reintroduced.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…pe-test after rebase

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…structions

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…regression anchor

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
nsId,
blindCast<
Record<string, ContractModel>,
'ns.models is a ContractModel record in the emitted IR'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That does not really answer the question of why type cast is needed. Why isn't ns.models compatible with Record<string, ContractModel>?

// so we check that emailAddress is present (it must appear twice: in the flatten and
// in the per-namespace auth block) and that roleLabel only appears once (per-namespace
// public block only, not in the flattened top-level models).
// The flattened top-level models type is still first-name-wins (auth's User), but the

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still have flattened top level models?

TQueryOperationTypes extends Record<string, unknown> = Record<string, never>,
TFieldOutputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,
TFieldInputTypes extends Record<string, Record<string, unknown>> = Record<string, never>,
TFieldOutputTypes extends Record<string, Record<string, Record<string, unknown>>> = Record<

@SevInf SevInf Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split Record<string, Record<string, Record<string, unknown>> to a separate named type and use it here and below?

return this.#toJoined().lateralJoin(alias, builder);
},
) as TableProxy<C, Name, Alias, AvailableScope, QC>['lateralJoin'];
) as TableProxy<C, string, Name, Alias, AvailableScope, QC>['lateralJoin'];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why aren't we forwarding NsId here?

NsId extends string,
TableName extends string,
> =
C extends Contract<SqlStorage>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand TableProxyContract to not have to do this check

ModelName extends string,
ColumnName extends string,
> =
C extends Contract<SqlStorage>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand TableProxyContract to not have to do this check

: Record<string, never>
: Record<string, never>
> =
C extends Contract<SqlStorage>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand TableProxyContract to not have to do this check

};
};

// Field-type maps are nested by namespace coordinate; this fixture's models

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have eyes, I can see that, I don't need this comment

… (ADR 224/225)

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
@SevInf SevInf force-pushed the explicit-namespace-slice2 branch from 3a960a9 to 3058eae Compare June 12, 2026 15:58
SevInf added 2 commits June 12, 2026 16:38
- contract: extract NamespacedFieldTypeMap and reuse it for the TypeMaps
  output/input params and their *Of extractors (pure refactor).
- emitter: eliminate the ns.models blindCasts by typing the model-emit
  helpers (generateModelsType / generateFieldTypesMapsByNamespace /
  FieldTypeParamsResolver) and the EmissionSpi to ContractModelBase, the
  type ApplicationDomainNamespace.models actually carries. ContractModel
  adds nothing structurally over ContractModelBase, so this is behaviour-
  identical and drops the casts.
- sql-builder: carry domain on TableProxyContract so FindModelForTable /
  FindFieldForColumn index C directly without a Contract<SqlStorage> guard.
  ResolvedColumnTypes keeps the guard (documented): it is required by
  ComputeColumnJsType, whose constraint lives in sql-relational-core.
- sql-builder: thread NsId through TableProxyImpl so as()/lateralJoin/
  outerLateralJoin forward the real coordinate instead of hardcoding
  string; the runtime Proxy boundary still defaults NsId to string (no
  static literal), now documented.
- tests: delete a redundant comment; answer "why keep the flat models"
  inline in the multi-namespace emitter test.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
…tire the last TableProxyContract guard

Define the minimal ColumnResolutionContract (per-namespace domain.models +
storage.entries.table; the refined field-output map is read structurally via
the optional TypeMaps phantom key) and relax ComputeColumnJsType and its six
helper aliases from Contract<SqlStorage> to it. Every emitted Contract<SqlStorage>
satisfies the shape, as does sql-builder TableProxyContract, so ResolvedColumnTypes
indexes C directly and drops its C extends Contract<SqlStorage> guard -- the last
of the three. Resolution stays per-namespace; no flat map is read.

Signed-off-by: Serhii Tatarintsev <tatarintsev@prisma.io>
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