Skip to content

TML-2605: namespace-qualify runtime SQL via per-family default namespace#670

Open
wmadden-electric wants to merge 20 commits into
mainfrom
tml-2605-runtime-qualification
Open

TML-2605: namespace-qualify runtime SQL via per-family default namespace#670
wmadden-electric wants to merge 20 commits into
mainfrom
tml-2605-runtime-qualification

Conversation

@wmadden-electric
Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-2605. Final slice of the Target-Extensible IR + Namespaces project — the runtime query path was the last consumer still namespace-blind after the IR became fully namespaced. Builds on the symmetric-domain-plane slice (which deliberately left transitional projection helpers for this slice to retire). The explicit namespace-aware surface (db.sql.auth.user, db.auth.User) is the follow-up, TML-2550.

At a glance

Application code stays flat — no query-code changes for existing single-namespace consumers:

const rows = await db.sql.user.findMany();

What changed is the SQL that comes out the other side. The contract IR has been fully namespaced for a while (storage.namespaces.public.tables.user), but the runtime still rendered the bare name. It now renders the qualified identifier its coordinate already implies:

-- before:  FROM "user"
-- after:   FROM "public"."user"

SQLite renders unqualified ("user", single-namespace no-op); Mongo addresses the collection in the right namespace's database.

Summary

Make the runtime query path namespace-aware: a bare query name resolves through a per-family default namespace and renders through its namespace's qualification, so emitted SQL matches the schema the IR already describes. This is the migration that takes the runtime from namespace-blind to namespace-aware, and it retires the throw-on-multi-namespace projection helpers the previous slice left as a bridge.

The decision

Four coupled pieces, all facets of "a bare query name now resolves and renders through its namespace" — see ADR 223:

  1. Namespace identity is resolved once and carried to the renderer. The DSL proxy and ORM accessor already decide which namespace owns a bare name when they build the query — then used to discard it. The resolved namespace coordinate is now carried on the relational AST (TableSource.namespaceId), set where resolution already happens, and the family adapter renders qualification via the namespace concretion's qualifyTable(). It is never re-derived by bare name at render time.
  2. A per-family default-namespace runtime constant (public for Postgres, __unbound__ for SQLite/Mongo). Authoring already centralised this rule; the runtime now has an importable equivalent, and every flat-name lookup resolves default-namespace-first instead of scanning in insertion order.
  3. Runtime resolves; the emitter stays fail-loud. Runtime resolves default-first and does not throw on multi-namespace contracts. Contract emission keeps its single-namespace guard (assertSingleDomainNamespaceForEmission) because per-namespace contract.d.ts is co-designed with the explicit surface in TML-2550. The two intentionally diverge until then.
  4. Retire the transitional projection helpers. contractModels / contractValueObjects / resolveSingleDomainNamespaceId and the ContractModelsMap / ContractValueObjectsMap type maps are removed from the foundation contract package, replaced by default-namespace access helpers — see ADR 221 for the IR shape these sit on.

How it fits together

  1. Default-namespace foundation. New per-family/target default-namespace constants and a shared default-first storage-table resolver in @prisma-next/contract, re-exported through the family runtime facades.
  2. AST coordinate. relational-core's TableSource gains an optional namespaceId; the sql-builder proxy stamps it at construction.
  3. Adapter rendering. The Postgres renderer qualifies FROM/INSERT/UPDATE/DELETE identifiers via the namespace's qualifyTable; SQLite does the same through its no-op. Column refs stay alias-qualified (unchanged).
  4. ORM path. sql-orm-client query plans resolve models/tables default-first and stamp the same coordinate, so DSL and ORM render identically.
  5. Type parity. query-builder's flat table types are brought to parity with sql-builder's cross-namespace + default-namespace resolution (a Postgres public contract no longer types its tables as never).
  6. Helper retirement + typed qualifyTable. The transitional helpers are removed; runtime consumers use default-first access helpers, the emitter uses an explicit single-namespace assertion, and qualifyTable becomes a typed member of the SQL namespace concretions.

Behavior changes & evidence

Notes for the reviewer

  • Largest commits to spot-check: 2482d2db7 (helper retirement + runtime/emitter split) and e8a054684 / 98bcba9a6 (renderer + AST coordinate). The renderer/AST pair is the load-bearing change.
  • Render-time-by-name was deliberately rejected (see Alternatives). Carrying the coordinate looks like a larger diff than a renderer-only lookup, but it's the seam TML-2550 extends rather than tears out.
  • The runtime/emitter divergence is intentional, not an oversight: runtime is permissive on multi-namespace contracts, the emitter is not, until per-namespace emission lands in TML-2550.
  • Test-harness fix, not a runtime workaround: several integration setups switched off structuredClone (which strips the qualifyTable method off a hydrated contract) onto a PostgresContractSerializer JSON round-trip. The root cause of the post-refactor integration reds was clone-induced method loss, not missing qualification logic.
  • Gate caveats ruled pre-existing / environmental (none reproduce from this slice's diff): test:integration passes 1015/1015 but exits 1 on PGlite teardown noise; test:packages fails only @prisma-next/cli-telemetry with prisma-next: command not found (the slice touches zero cli-telemetry files; the local worktree lacked the .bin/prisma-next symlink and runs Node 22 against an engines.node >= 24); fixtures:check needs the CLI on PATH locally — contract.* fixtures were confirmed clean via canonical emit.

Compatibility / migration / risk

Breaking for extension authors and SPI consumers: the removed contract helpers and the new qualifyTable expectation on SQL namespace concretions require code changes. Upgrade instructions are recorded for both the user surface (skills/upgrade/.../0.11-to-0.12/instructions.md) and the extension-author surface (skills/extension-author/.../0.11-to-0.12/instructions.md), with an old→new mapping table. Single-namespace Postgres application code needs no changes.

Testing performed

  • pnpm typecheck — pass (135/135).
  • pnpm test:integration — 1015/1015 tests pass (process exit 1 on PGlite teardown noise, ruled pre-existing).
  • pnpm test:e2e — pass (105 tests, incl. the new multi-namespace proof).
  • pnpm lint:deps — pass.
  • pnpm fixtures:checkcontract.* confirmed clean via canonical CLI emit (root script needs CLI on PATH locally).
  • pnpm test:packages — 695/699 files pass; only the pre-existing @prisma-next/cli-telemetry command not found failure remains (environmental, not from this slice).

Skill update

Upgrade-instruction skills updated (user + extension-author 0.11→0.12 transitions) for the removed helpers, the qualifyTable expectation, and namespace-qualified SQL. No CLI/config surface changed.

Follow-ups

  • TML-2550 — explicit namespace-aware surface (db.sql.<ns>.<table>, db.<ns>.<Model>), cross-namespace collision ergonomics, and per-namespace contract.d.ts emission. Builds directly on the AST coordinate this slice introduces.

Alternatives considered

  • Render-time resolution by bare name (renderer re-looks-up the name in contract.storage default-first). Smaller diff, but it re-derives what the proxy already knew and would diverge from the proxy's choice for colliding names — db.sql.auth.user would render "public"."user". TML-2550 would have to rip it out. Carrying the coordinate on the AST is the extension seam, not a throwaway.
  • Folding the convention into ADR 221. "A family façade owns its default namespace" is a convention future families inherit, distinct from ADR 221's IR-shape decisions, so it gets its own ADR (223).
  • Keeping the transitional projection helpers. They throw on multi-namespace contracts and encode a single-namespace assumption the runtime no longer makes; leaving them would keep a half-namespaced runtime. The previous slice named this slice as their owner.

Checklist

  • All commits are signed off (git commit -s) per the DCO.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated.
  • The PR title is in TML-NNNN: <sentence-case title> form.
  • The Skill update section above is filled in.

wmadden added 17 commits June 1, 2026 15:04
Signed-off-by: Will Madden <madden@prisma.io>
…lane

Centralise POSTGRES_DEFAULT_DOMAIN_NAMESPACE_ID and per-target helpers,
add resolveDomainModel with default-namespace-first ordering, and retarget
resolveSingleDomainNamespaceId to infer public then unbound when multiple
namespaces are declared.

Signed-off-by: Will Madden <madden@prisma.io>
Export POSTGRES_DEFAULT_STORAGE_NAMESPACE_ID, defaultStorageNamespaceIdForSqlTarget,
and resolveStorageTable with default-namespace-first ordering. Re-export from
family-sql/runtime and add Mongo-family default namespace identifiers.

Signed-off-by: Will Madden <madden@prisma.io>
Thread resolved storage namespace id from resolveStorageTable (default-first)
through the flat db.sql table proxy into TableSource, and preserve it across
select/insert/update/delete plan construction.

Signed-off-by: Will Madden <madden@prisma.io>
Postgres and SQLite renderers call namespace concretion qualifyTable() using
the namespaceId stamped on TableSource (no render-time bare-name resolution).
SqliteContractSerializer hydrates table-bearing unbound namespaces as
SqliteDatabase so runtime contracts expose qualifyTable.

Signed-off-by: Will Madden <madden@prisma.io>
After sql-contract dist changes, rolldown-plugin-dts could not name the
inferred return type across the package boundary (TS2742). Use an explicit
ReturnType<typeof buildSqlNamespace> so sql-runtime builds cleanly.

Signed-off-by: Will Madden <madden@prisma.io>
… nodes

Route model and table resolution through D1 default-namespace-first APIs
(resolveDomainModel, resolveStorageTable) and build every ORM TableSource via
tableSourceForContract so adapter renderers qualify SQL like the DSL path.

Signed-off-by: Will Madden <madden@prisma.io>
Reuse sql-builder cross-namespace table types for UnboundTables so
Postgres public contracts type-check on root.from and the flat ref
surface; add vitest type tests against the sql-builder postgres fixture.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Signed-off-by: Will Madden <madden@prisma.io>
Regenerate showcase migration end-contract.d.ts with explicit namespaced
domain emission (__unbound__ slot matches JSON). Restore telemetry-backend
migration end-contract artefacts accidentally dropped from the branch.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Signed-off-by: Will Madden <madden@prisma.io>
Remove contractModels, contractValueObjects, resolveSingleDomainNamespaceId,
ContractModelsMap, and ContractValueObjectsMap from foundation contract.
Runtime consumers use domainModelsAtDefaultNamespace and default-namespace
resolvers; the emitter asserts a single domain namespace and throws on
multi-namespace contracts. Regenerated contract.d.ts fixtures use infer-based
Models export aligned with the framework emitter template.

Signed-off-by: Will Madden <madden@prisma.io>
…ering (D5b)

Declare qualifyTable on the family SqlNamespace type and implement it on
SqlBoundNamespace and SqlUnboundNamespace so adapters call namespace.qualifyTable
without bare casts. Renderers guard when a namespace entry is not materialised.
Fix adapter-postgres qualification tests to use package imports and the
renderLoweredSql codecLookup argument.

Signed-off-by: Will Madden <madden@prisma.io>
…pace SQL (D7)

Postgres integration paths deserialize contracts with PostgresContractSerializer
and re-hydrate clones instead of structuredClone so qualifyTable survives.
CLI journey migrations hydrate end-contract.json before sql-builder lowering.
Add PGlite e2e proof for auth + public namespace-qualified SELECT.
Reconcile emitted contract.d.ts fixtures via canonical CLI emit.

Signed-off-by: Will Madden <madden@prisma.io>
…ck (D7)

Signed-off-by: Will Madden <madden@prisma.io>
Record the default-namespace family façade convention, retire transitional
contract projection helpers in upgrade guidance, and document Postgres
namespace-qualified runtime SQL for users and extension authors.

Signed-off-by: Will Madden <madden@prisma.io>
ADRs are durable docs and must not link to transient project artefacts
under projects/; the slice-spec path would dangle at project close-out.
The ADR body is self-contained, so the reference is removed rather than
re-pointed.

Signed-off-by: Will Madden <madden@prisma.io>
…ade snippet

The hydration example used a static deserialize/serialize API from the
/contract subpath; the real serializer is instance-based
(serializeContract/deserializeContract) on /runtime. Extension authors
copy this snippet verbatim, so the wrong API would mislead.

Signed-off-by: Will Madden <madden@prisma.io>
…ace test

PDoD7 is a transient project done-condition id; source/test comments and
describe names must not reference transient project-planning artefacts.
Describe the property the test pins instead.

Signed-off-by: Will Madden <madden@prisma.io>
@wmadden-electric wmadden-electric requested a review from a team as a code owner June 1, 2026 15:08
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Important

Review skipped

Too many files!

This PR contains 156 files, which is 6 over the limit of 150.

To get a review, narrow the scope:
• coderabbit review --type committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 37e372a8-df10-43de-ba84-27fbeb956503

📥 Commits

Reviewing files that changed from the base of the PR and between f78139a and d9e8b1e.

⛔ 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/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • projects/target-extensible-ir-namespaces/slices/runtime-qualification/plan.md is excluded by !projects/**
  • projects/target-extensible-ir-namespaces/slices/runtime-qualification/spec.md is excluded by !projects/**
  • 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/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/**
📒 Files selected for processing (156)
  • apps/telemetry-backend/migrations/app/20260601T1236_contract_hash_advance/end-contract.d.ts
  • apps/telemetry-backend/migrations/app/20260601T1236_contract_hash_advance/end-contract.json
  • apps/telemetry-backend/src/prisma/contract.d.ts
  • docs/architecture docs/adrs/ADR 223 - Default namespace family façade convention.md
  • examples/mongo-blog-leaderboard/src/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/migrations/20260601T0000_create_audit_event/end-contract.d.ts
  • examples/multi-extension-monorepo/packages/audit/src/contract.d.ts
  • examples/multi-extension-monorepo/packages/feature-flags/migrations/20260601T0000_create_feature_flag/end-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/migration-fixtures/showcase/app/20260601T0719_init/end-contract.d.ts
  • examples/prisma-next-demo/src/app/ContractView.tsx
  • examples/prisma-next-demo/src/prisma/contract.d.ts
  • examples/prisma-next-demo/test/demo-dx.integration.test.ts
  • examples/prisma-next-postgis-demo/src/prisma/contract.d.ts
  • examples/react-router-demo/src/prisma/contract.d.ts
  • examples/retail-store/src/contract.d.ts
  • packages/1-framework/0-foundation/contract/package.json
  • packages/1-framework/0-foundation/contract/src/contract-types.ts
  • packages/1-framework/0-foundation/contract/src/default-namespace.ts
  • packages/1-framework/0-foundation/contract/src/domain-envelope.ts
  • packages/1-framework/0-foundation/contract/src/domain-namespace-access.ts
  • packages/1-framework/0-foundation/contract/src/exports/default-namespace.ts
  • packages/1-framework/0-foundation/contract/src/exports/resolve-domain-model.ts
  • packages/1-framework/0-foundation/contract/src/exports/types.ts
  • packages/1-framework/0-foundation/contract/src/resolve-domain-model.ts
  • packages/1-framework/0-foundation/contract/test/contract-types.test-d.ts
  • packages/1-framework/0-foundation/contract/test/contract-types.test.ts
  • packages/1-framework/0-foundation/contract/test/default-namespace.test.ts
  • packages/1-framework/0-foundation/contract/test/resolve-domain-model.test.ts
  • packages/1-framework/0-foundation/contract/tsdown.config.ts
  • packages/1-framework/3-tooling/emitter/src/assert-single-domain-namespace-for-emission.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/assert-single-domain-namespace-for-emission.test.ts
  • packages/1-framework/3-tooling/emitter/test/domain-type-generation.test.ts
  • packages/1-framework/3-tooling/emitter/test/emitter.test.ts
  • packages/1-framework/3-tooling/emitter/test/utils.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/package.json
  • packages/2-mongo-family/1-foundation/mongo-contract/src/contract-types.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/default-namespace.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/src/exports/index.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/default-namespace.test.ts
  • packages/2-mongo-family/1-foundation/mongo-contract/test/fixtures/orm-contract.d.ts
  • packages/2-mongo-family/2-authoring/contract-ts/src/contract-builder.ts
  • packages/2-mongo-family/2-authoring/contract-ts/test/contract-builder.dsl.test.ts
  • packages/2-mongo-family/5-query-builders/orm/src/collection.ts
  • packages/2-mongo-family/5-query-builders/orm/src/field-accessor.ts
  • packages/2-mongo-family/5-query-builders/orm/src/mongo-raw.ts
  • packages/2-mongo-family/5-query-builders/query-builder/src/builder.ts
  • packages/2-mongo-family/5-query-builders/query-builder/src/lookup-builder.ts
  • packages/2-mongo-family/5-query-builders/query-builder/src/resolve-path.ts
  • packages/2-mongo-family/5-query-builders/query-builder/src/state-classes.ts
  • packages/2-mongo-family/9-family/package.json
  • packages/2-mongo-family/9-family/src/core/default-namespace.ts
  • packages/2-mongo-family/9-family/src/exports/runtime.ts
  • packages/2-mongo-family/9-family/tsdown.config.ts
  • packages/2-sql/1-core/contract/package.json
  • packages/2-sql/1-core/contract/src/default-namespace.ts
  • packages/2-sql/1-core/contract/src/exports/default-namespace.ts
  • packages/2-sql/1-core/contract/src/exports/resolve-storage-table.ts
  • packages/2-sql/1-core/contract/src/ir/build-sql-namespace.ts
  • packages/2-sql/1-core/contract/src/ir/sql-storage.ts
  • packages/2-sql/1-core/contract/src/ir/sql-unbound-namespace.ts
  • packages/2-sql/1-core/contract/src/resolve-storage-table.ts
  • packages/2-sql/1-core/contract/test/default-namespace.test.ts
  • packages/2-sql/1-core/contract/test/resolve-storage-table.test.ts
  • packages/2-sql/1-core/contract/tsdown.config.ts
  • packages/2-sql/2-authoring/contract-psl/test/fixtures.ts
  • packages/2-sql/2-authoring/contract-ts/test/config-types.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-builder.dsl.test.ts
  • packages/2-sql/2-authoring/contract-ts/test/contract-test-helpers.ts
  • packages/2-sql/3-tooling/emitter/src/index.ts
  • packages/2-sql/4-lanes/query-builder/package.json
  • packages/2-sql/4-lanes/query-builder/src/selection.ts
  • packages/2-sql/4-lanes/query-builder/test/cross-namespace-tables.types.test-d.ts
  • packages/2-sql/4-lanes/query-builder/tsconfig.json
  • packages/2-sql/4-lanes/query-builder/vitest.config.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/types.ts
  • packages/2-sql/4-lanes/relational-core/src/types.ts
  • packages/2-sql/4-lanes/sql-builder/src/exports/types.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/mutation-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/resolve-table.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/sql.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/table-proxy-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/table-source-for-proxy.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/runtime/builders.test.ts
  • packages/2-sql/4-lanes/sql-builder/test/runtime/default-namespace-qualification.test.ts
  • packages/2-sql/5-runtime/test/utils.ts
  • packages/2-sql/9-family/src/core/default-namespace.ts
  • packages/2-sql/9-family/src/exports/runtime.ts
  • packages/2-sql/9-family/test/cross-reference-roundtrip.test.ts
  • packages/3-extensions/mongo/test/contract-builder/define-contract.test-d.ts
  • packages/3-extensions/mongo/test/contract-builder/define-contract.test.ts
  • packages/3-extensions/paradedb/migrations/20260601T0000_install_pg_search_extension/end-contract.d.ts
  • packages/3-extensions/paradedb/src/contract.d.ts
  • packages/3-extensions/pgvector/migrations/20260601T0000_install_vector_extension/end-contract.d.ts
  • packages/3-extensions/pgvector/src/contract.d.ts
  • packages/3-extensions/postgis/migrations/20260601T0000_install_postgis_extension/end-contract.d.ts
  • packages/3-extensions/postgis/src/contract.d.ts
  • packages/3-extensions/postgres/test/contract-builder/define-contract.test-d.ts
  • packages/3-extensions/postgres/test/contract-builder/define-contract.test.ts
  • packages/3-extensions/sql-orm-client/src/collection-contract.ts
  • packages/3-extensions/sql-orm-client/src/model-accessor.ts
  • packages/3-extensions/sql-orm-client/src/orm.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-aggregate.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-meta.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-mutations.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-select.ts
  • packages/3-extensions/sql-orm-client/src/storage-resolution.ts
  • packages/3-extensions/sql-orm-client/src/types.ts
  • packages/3-extensions/sql-orm-client/test/collection-fixtures.ts
  • packages/3-extensions/sql-orm-client/test/collection-runtime.test.ts
  • packages/3-extensions/sql-orm-client/test/helpers.ts
  • packages/3-extensions/sql-orm-client/test/model-accessor.test.ts
  • packages/3-extensions/sql-orm-client/test/namespace-qualification.test.ts
  • packages/3-extensions/sql-orm-client/test/query-plan-select.test.ts
  • packages/3-extensions/sqlite/test/contract-builder/define-contract.test-d.ts
  • packages/3-extensions/sqlite/test/contract-builder/define-contract.test.ts
  • packages/3-targets/3-targets/sqlite/src/core/sqlite-contract-serializer.ts
  • packages/3-targets/3-targets/sqlite/src/core/sqlite-unbound-database.ts
  • packages/3-targets/3-targets/sqlite/src/exports/runtime.ts
  • packages/3-targets/3-targets/sqlite/test/sqlite-contract-serializer-hydration.test.ts
  • packages/3-targets/3-targets/sqlite/test/sqlite-unbound-database.test.ts
  • packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts
  • packages/3-targets/6-adapters/postgres/test/adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/sql-renderer-namespace-qualification.test.ts
  • packages/3-targets/6-adapters/sqlite/src/core/adapter.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.11-to-0.12/instructions.md
  • skills/upgrade/prisma-next-upgrade/upgrades/0.11-to-0.12/instructions.md
  • test/e2e/framework/test/multi-namespace-runtime.test.ts
  • test/e2e/framework/test/utils.ts
  • test/integration/test/cli-journeys/data-transform-enum-rebuild.e2e.test.ts
  • test/integration/test/cli-journeys/data-transform-not-null-backfill.e2e.test.ts
  • test/integration/test/cli-journeys/data-transform-nullable-tightening.e2e.test.ts
  • test/integration/test/cli-journeys/data-transform-type-change.e2e.test.ts
  • test/integration/test/cli-journeys/invariant-routing.e2e.test.ts
  • test/integration/test/cli-journeys/migration-round-trip.e2e.test.ts
  • test/integration/test/contract-builder.types.test-d.ts
  • test/integration/test/contract-imports.test.ts
  • test/integration/test/dsl-type-inference.test-d.ts
  • test/integration/test/fixtures/contract.d.ts
  • test/integration/test/sql-builder/setup.ts
  • test/integration/test/sql-orm-client/collection-fixtures.ts
  • test/integration/test/sql-orm-client/collection-mutation-defaults.test.ts
  • test/integration/test/sql-orm-client/helpers.ts
  • test/integration/test/sql-orm-client/nested-includes-helpers.ts
  • test/integration/test/sql-orm-client/upsert.test.ts
  • test/integration/test/utils/journey-test-helpers.ts
  • test/integration/test/value-objects/value-objects.integration.test.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2605-runtime-qualification

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: d9e8b1e

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

size-limit report 📦

Path Size
postgres / no-emit 136.57 KB (+0.47% 🔺)
postgres / emit 126.23 KB (+0.52% 🔺)
mongo / no-emit 75.78 KB (+0.12% 🔺)
mongo / emit 70.77 KB (+0.13% 🔺)

wmadden added 3 commits June 1, 2026 17:42
Refactor assertSingleDomainNamespaceForEmission to destructure namespace keys
so every branch is reachable and unit-tested. Add direct tests for zero, one,
and many namespaces; extend emitter tests for missing namespace payloads and
value object emission. Drop an unreachable resolveFieldTypeParams guard.

Also fix sql-contract lint: prefix unused tableNamed parameter with underscore.

Signed-off-by: Will Madden <madden@prisma.io>
Refresh committed contract.d.ts fixtures after a full build so emit matches
the current CLI: add StorageBase to contract type imports and export Models
above Contract.

Signed-off-by: Will Madden <madden@prisma.io>
Pass the iterated ContractModel into FieldTypeParamsResolver so
generate-contract-dts does not re-index modelsRecord under
noUncheckedIndexedAccess. Extend TestContractOverrides with valueObjects
and cast the missing-namespace negative test contract via unknown.

Signed-off-by: Will Madden <madden@prisma.io>
Copy link
Copy Markdown
Contributor

@wmadden wmadden left a comment

Choose a reason for hiding this comment

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

Unacceptable. You moved target-specific logic into the framework domain

Comment on lines +141 to +144
domainModelsAtDefaultNamespace(
contract.domain,
defaultDomainNamespaceIdForSqlTarget(contract.target),
) as Models,
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.

This isn't good enough. This example app exists to prove that walking the Contract type is ergonomic. This cast, and the domainModelsAtDefaultNamespace() and defaultDomainNamespaceIdForSqlTarget() helpers fail the test

readonly profileHash: ProfileHash;
};

export type Models = Contract extends ContractType<StorageBase, infer TModels> ? TModels : never;
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.

Don't love this, for the same reason. Why are we generating types which need to be interpolated?

defaultDomainNamespaceIdForMongo,
defaultDomainNamespaceIdForSqlTarget,
inferDefaultDomainNamespaceId,
POSTGRES_DEFAULT_DOMAIN_NAMESPACE_ID,
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.

WOW YOU'RE KIDDING? A postgres constant in the framework domain?

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.

Completely unacceptable. SQL and Postgres constants in the framework domain

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.

2 participants