Repository navigation
TML-2816: always-qualified sql/orm builder + per-facade db projection - #778
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR makes the SQL/ORM API namespace-first: flat table/model access is removed; call sites now use ChangesNamespace qualification migration
Estimated code review effort Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
|
size-limit report 📦
|
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
There was a problem hiding this comment.
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 `@test/integration/test/value-objects/value-objects.e2e.test.ts`:
- Line 6: Replace the use of UNBOUND_NAMESPACE_ID when indexing sqlOrm({
runtime, context }) with the Postgres namespace facet constant used by the
qualified namespace contract (import the Postgres namespace constant from the
module that exports the DB namespace facets) so you obtain the Postgres-specific
client facet instead of an unbound one; update both occurrences (the import and
the index usages around sqlOrm({ runtime, context })[UNBOUND_NAMESPACE_ID]!) to
import and reference the Postgres namespace constant and keep the non-null check
to ensure the client facet is defined.
🪄 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: 6ac58a2c-7738-4f96-92e0-42171e70ca14
⛔ Files ignored due to path filters (4)
projects/explicit-namespace-dsl/adr-draft-always-qualified-builder-surface.mdis excluded by!projects/**projects/explicit-namespace-dsl/learnings.mdis excluded by!projects/**projects/explicit-namespace-dsl/slices/02-remove-flat-fallback/plan.mdis excluded by!projects/**projects/explicit-namespace-dsl/subagent-registry.mdis excluded by!projects/**
📒 Files selected for processing (97)
apps/telemetry-backend/src/handler.tsapps/telemetry-backend/test/handler.test.tsapps/telemetry-backend/test/rate-limit.handler.test.tsexamples/bundle-size/src/postgres-worker/worker-emit.tsexamples/bundle-size/src/postgres-worker/worker.tsexamples/bundle-size/src/postgres/main-emit.tsexamples/bundle-size/src/postgres/main.tsexamples/paradedb-demo/scripts/seed.tsexamples/paradedb-demo/src/orm-client/client.tsexamples/paradedb-demo/src/queries/bm25-cast-demo.tsexamples/paradedb-demo/src/queries/bm25-chain-demo.tsexamples/paradedb-demo/src/queries/bm25-fuzzy.tsexamples/paradedb-demo/src/queries/bm25-match.tsexamples/paradedb-demo/src/queries/bm25-mode-tour.tsexamples/paradedb-demo/src/queries/bm25-proximity-chain.tsexamples/paradedb-demo/src/queries/bm25-proximity.tsexamples/paradedb-demo/src/queries/bm25-top-by-score.tsexamples/prisma-next-cloudflare-worker/README.mdexamples/prisma-next-cloudflare-worker/scripts/seed.tsexamples/prisma-next-cloudflare-worker/src/orm-client/client.tsexamples/prisma-next-cloudflare-worker/src/worker.tsexamples/prisma-next-demo-sqlite/src/orm-client/client.tsexamples/prisma-next-demo/README.mdexamples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.tsexamples/prisma-next-demo/scripts/seed.tsexamples/prisma-next-demo/src/orm-client/client.tsexamples/prisma-next-demo/src/prisma-no-emit/context.tsexamples/prisma-next-demo/src/queries/cross-author-similarity.tsexamples/prisma-next-demo/src/queries/delete-without-where.tsexamples/prisma-next-demo/src/queries/dml-operations.tsexamples/prisma-next-demo/src/queries/get-all-posts-unbounded.tsexamples/prisma-next-demo/src/queries/get-user-by-email-prepared.tsexamples/prisma-next-demo/src/queries/get-user-by-id.tsexamples/prisma-next-demo/src/queries/get-user-posts.tsexamples/prisma-next-demo/src/queries/get-users-cached.tsexamples/prisma-next-demo/src/queries/get-users.tsexamples/prisma-next-demo/src/queries/raw-sql-demo.tsexamples/prisma-next-demo/src/queries/similarity-search.tsexamples/prisma-next-demo/test/repositories.integration.test.tsexamples/prisma-next-demo/test/runtime.offline.integration.test.tsexamples/prisma-next-demo/test/sql-dsl.integration.test.tsexamples/prisma-next-postgis-demo/README.mdexamples/prisma-next-postgis-demo/app/lib/queries-meta.tsexamples/prisma-next-postgis-demo/scripts/seed.tsexamples/prisma-next-postgis-demo/src/queries/find-cafes-in-bbox.tsexamples/prisma-next-postgis-demo/src/queries/find-cafes-in-neighborhood.tsexamples/prisma-next-postgis-demo/src/queries/find-cafes-near-point.tsexamples/prisma-next-postgis-demo/src/queries/find-cafes-within-radius.tsexamples/prisma-next-postgis-demo/src/queries/find-neighborhood-for-point.tsexamples/prisma-next-postgis-demo/src/queries/find-routes-intersecting.tsexamples/prisma-next-postgis-demo/test/queries.e2e.test.tsexamples/react-router-demo/app/routes/users.tsxexamples/supabase/test/skeleton.integration.test.tspackages/2-sql/4-lanes/sql-builder/src/runtime/resolve-table.tspackages/2-sql/4-lanes/sql-builder/src/runtime/sql.tspackages/2-sql/4-lanes/sql-builder/src/types/db.tspackages/2-sql/4-lanes/sql-builder/test/runtime/annotate.test.tspackages/2-sql/4-lanes/sql-builder/test/runtime/builders.test.tspackages/2-sql/4-lanes/sql-builder/test/runtime/default-namespace-qualification.test.tspackages/2-sql/4-lanes/sql-builder/test/runtime/namespaced-resolution.test.tspackages/2-sql/4-lanes/sql-builder/test/types/namespaced-db.types.test-d.tspackages/3-extensions/postgres/test/namespaced-facade.types.test-d.tspackages/3-extensions/postgres/test/raw-sql-composition.test.tspackages/3-extensions/sql-orm-client/src/orm.tspackages/3-extensions/sql-orm-client/src/storage-resolution.tspackages/3-extensions/sql-orm-client/test/orm-namespaced.test.tspackages/3-extensions/sql-orm-client/test/orm-namespaced.types.test-d.tspackages/3-extensions/sql-orm-client/test/orm.test.tspackages/3-extensions/sql-orm-client/test/orm.types.test-d.tspackages/3-extensions/sqlite/src/runtime/sqlite.tspackages/3-extensions/sqlite/test/fixtures/namespaced-contract.tspackages/3-extensions/sqlite/test/namespaced-facade.types.test-d.tspackages/3-extensions/sqlite/test/transaction.test.tsskills/extension-author/prisma-next-extension-upgrade/upgrades/0.12-to-0.13/instructions.mdskills/upgrade/prisma-next-upgrade/upgrades/0.12-to-0.13/instructions.mdtest/e2e/framework/test/arktype-json.test.tstest/e2e/framework/test/multi-namespace-runtime.test.tstest/e2e/framework/test/sqlite/raw-sql.test.tstest/e2e/framework/test/sqlite/runtime.verify-marker.missing-table.test.tstest/e2e/framework/test/sqlite/utils.tstest/e2e/framework/test/transaction-orm.test.tstest/e2e/framework/test/utils.tstest/integration/test/cli-journeys/init-journey.e2e.test.tstest/integration/test/cli-journeys/invariant-routing.e2e.test.tstest/integration/test/cli-journeys/migration-round-trip.e2e.test.tstest/integration/test/contract-builder.test.tstest/integration/test/contract-builder.types.test-d.tstest/integration/test/cross-package/middleware-cache.test.tstest/integration/test/dsl-type-inference.test-d.tstest/integration/test/rewriting-middleware.integration.test.tstest/integration/test/runtime.verify-marker.missing-table.integration.test.tstest/integration/test/sql-builder/playground/preamble.tstest/integration/test/sql-builder/raw-sql.integration.test.tstest/integration/test/sql-builder/setup.tstest/integration/test/sql-orm-client/orm.test.tstest/integration/test/utils/journey-test-helpers.tstest/integration/test/value-objects/value-objects.e2e.test.ts
💤 Files with no reviewable changes (2)
- packages/3-extensions/sql-orm-client/src/storage-resolution.ts
- packages/2-sql/4-lanes/sql-builder/src/runtime/resolve-table.ts
315ba8e to
6734553
Compare
Db<C> collapses to the namespaced-only mapped type
({ [Ns in keyof storage.namespaces]: Namespace<C, Ns> }); the flat
intersection member is gone. sql() resolves namespace facets only --
the resolveTableForFlatName fallback branch and the helper are deleted
(resolveTableInNamespace stays). Namespace selection is now mandatory;
flat sql.<table> is a compile error and a runtime undefined.
UnboundTables / TableNamesAcrossNamespaces are retained (load-bearing
generic constraints for TableProxy and the query-builder package).
Tests: negative type test asserts the flat Db<C> key is gone; runtime
tests alias their db() helper to the public namespace facet (the sole
shape); the interim flat-throw assertions are retargeted to
flat-access-yields-undefined.
Breaking: builder-layer flat accessors removed (project FR6). Workspace
typecheck goes red on facades + flat consumers until later dispatches.
Signed-off-by: Serhii Tatarintsev <[email protected]>
OrmClient collapses to the namespaced-only mapped type
(NamespacedClientMap); the flat ModelCollectionMap intersection member is
gone. orm() resolves namespace facets only -- the bare-model flat branch,
the flatCollection helper, and its flatCache are deleted (the namespace
facet is the sole model-resolution path). Namespace selection is now
mandatory; flat orm.<Model> is a compile error and a runtime undefined.
soleDomainNamespaceId stays a foundation helper; only its orm.ts use (in
flatCollection) goes. domainModelsAtDefaultNamespace is retained -- the
custom-collection registry still validates custom keys against it. The
orphaned domainModelNames / soleDomainNamespaceId imports are dropped.
Tests: negative type tests assert the flat OrmClient key is gone; runtime
+ trait-gating tests alias their orm() client to the public namespace
facet (the sole shape); the unknown-model throw is retargeted to the
facet ("No model <x> in namespace <ns>"); the interim flat-throw
assertion is retargeted to flat-access-yields-undefined.
Breaking: builder-layer flat accessors removed (project FR6). Mirrors the
SQL builder cut (3b8e50f39). Workspace typecheck stays red on facades +
flat consumers until later dispatches.
Signed-off-by: Serhii Tatarintsev <[email protected]>
The flat by-bare-model cut (a17238845) removed the sole caller of domainModelNames (the orm() modelNames set). Repo-wide it now has zero consumers and is not re-exported on any barrel; its live successor for the namespaced path is domainModelNamesInNamespace. Remove the dead definition. Signed-off-by: Serhii Tatarintsev <[email protected]>
…espace Each sql-family facade returns its own default-namespace projection of the (now namespaced-only) builder outputs -- no shared helper, no descriptor read, no per-target switch: - postgres (multi-namespace): db.sql = sql, db.orm = orm stay the qualified map. Call sites write db.sql.public.users / db.orm.public.User; flat db.sql.users / db.orm.User are type errors. No runtime change -- only the facade type-tests flip flat -> @ts-expect-error. - sqlite (single-namespace): db.sql = sql[__unbound__], db.orm = orm[__unbound__] via a small unboundFacet() alias (keyed on the UNBOUND_NAMESPACE_ID constant), restoring flat db.sql.users / db.orm.User. Same in the transaction context + prepare callback typing. The generic builder value indexes to a string-keyed facet, so unboundFacet bridges to the literal-keyed type with one narrowed blindCast (the unbound namespace always exists on a sqlite contract). Reconciles the sqlite facade fixture to a sole __unbound__ namespace (was main) so the alias resolves. Migrates the two in-package flat-builder consumers the cut broke at runtime (postgres raw-sql-composition: qualify db.__unbound__.users on the unbound stub; sqlite transaction.test: mock builders now expose the proxy under the __unbound__ facet key). Projection dispatches purely on the facade each target ships (AC5: no per-target switch). Mongo is a separate dispatch. Signed-off-by: Serhii Tatarintsev <[email protected]>
The SQL builder/ORM surfaces are namespaced-only post-D1/D2. Migrate the
integration-tests consumers off the removed flat surface:
- Alias the two shared construction helpers once (collapses ~535 sites):
sql-builder/playground/preamble.ts (db: Db<C>['public']) and
sql-builder/setup.ts (db() -> sql({...}).public).
- Qualify the remaining inline sql({...})/orm({...}) constructions to
their namespace facet (.public for the postgres fixtures; the unbound
facet via UNBOUND_NAMESPACE_ID for the value-objects __unbound__ SQL
contract).
Behaviour-preserving: every test exercises the same tables/models/shapes
through the qualified facet.
Signed-off-by: Serhii Tatarintsev <[email protected]>
The SQL builder/ORM surfaces are namespaced-only post-D1/D2. Migrate the e2e-tests consumers off the removed flat surface: - Alias the two shared harness helpers once: withTestRuntime (postgres, db -> .public facet) and withSqliteTestRuntime (sqlite, db + ormClient -> the unbound facet via a single narrowed blindCast, since indexing a generic builder value widens the namespace key). - multi-namespace-runtime: qualify each table to its own namespace (db.auth.user / db.public.note), matching the asserted qualified SQL. - transaction-orm (postgres facade): orm.<Model> -> orm.public.<Model>. - arktype-json (postgres facade): same. - sqlite raw-sql + verify-marker: alias the inline db construction (and its harness type) to the unbound facet. Behaviour-preserving: every test exercises the same tables/models/shapes through the qualified facet. Signed-off-by: Serhii Tatarintsev <[email protected]>
The journey tests scaffold user code (migration data-transform lambdas and an init-journey runtime check) that is written to disk and executed via tsx, so flat builder access on the now-namespaced-only surface would fail at journey runtime (not caught by static typecheck since the code lives in string literals). Alias each postgres scaffold db to the .public facet (so injected db.<table> lambdas resolve flat) and qualify the init-journey facade scaffold to db.orm.public.User. Signed-off-by: Serhii Tatarintsev <[email protected]>
The SQL builder/ORM surfaces are namespaced-only post-D1/D2, and the postgres facade is qualified-only post-D3. Migrate the postgres example apps off the removed flat surface: db.sql.<table> -> db.sql.public.<table>, db.orm.<Model> -> db.orm.public.<Model>; alias the builder-direct orm-client helpers (createOrmClient) to the public facet; qualify the prepare-callback and no-emit builder accesses. Covers prisma-next-demo, paradedb-demo, prisma-next-postgis-demo, prisma-next-cloudflare-worker, example-supabase, react-router-demo, bundle-size, and telemetry-backend. Behaviour-preserving: every query targets the same table/model through the qualified facet. Signed-off-by: Serhii Tatarintsev <[email protected]>
The ORM surface is namespaced-only; demo-sqlite builds a builder-direct ORM
client via createOrmClient. Alias it to the unbound namespace facet
(orm({...})[UNBOUND_NAMESPACE_ID]) so flat model access keeps working. The
facade consumers (db.sql.<table>) already resolve via the sqlite __unbound__
projection from D3, so they are unchanged.
Signed-off-by: Serhii Tatarintsev <[email protected]>
Update postgres example README snippets that showed the removed flat builder access (db.sql.<table> / db.orm.<Model>) to the qualified form (db.sql.public.<table> / db.orm.public.<Model>). D6 upgrade instructions reference this consumer-facing migration. Mongo example READMEs (root-keyed db.orm.<Model>) are unchanged. Signed-off-by: Serhii Tatarintsev <[email protected]>
…r upgrade entries ADR (project-local draft, migrates to docs/architecture docs/adrs/ at close-out) documenting the always-qualified builder surface, the per-facade static default-namespace projection (reconciling the stale descriptor-driven AC5 framing), the mongo root-keyed exception, and the Db<C> per-namespace facet construction; cross-linked to ADR 223 / TML-2605. Upgrade instructions for the breaking flat-accessor removal, recorded in both audience clusters (cross-audience: the change touches examples/ and packages/3-extensions/): qualify db.sql.<table>/db.orm.<Model> (and direct sql.<table>/orm.<Model>) to the namespace the table/model is declared in on postgres/multi-namespace contracts; sqlite/mongo single-namespace facade users unaffected. Signed-off-by: Serhii Tatarintsev <[email protected]>
…nknown access (FR11) The namespaced-only builder surfaces now fail fast with a diagnostic that names the namespace instead of returning undefined: - sql(): the top-level proxy throws "Unknown namespace <prop>. Available namespaces: <list>" for a non-namespace property (which includes flat bare-name access on the always-qualified surface); the namespace facet throws "No table <table> in namespace <ns>. Available tables: <list>" for an unknown table, mirroring the ORM facet's existing unknown-model diagnostic. - orm(): the top-level proxy throws the same unknown-namespace diagnostic (previously undefined); the facet-level unknown-model throw is unchanged. Both proxies still return undefined for symbol property access (inspection / Symbol.toStringTag), so only string mis-access fails fast. Brings the SQL builder + the unknown-namespace cases to parity with the ORM facet. Retargets the interim flat/unknown-access tests (D1/D2 asserted to undefined) to assert the fail-fast throw, and adds FR11 fail-fast tests in each package. Valid-namespace and single-namespace happy paths are unchanged. Signed-off-by: Serhii Tatarintsev <[email protected]>
…gistry Orchestrator-authored project artifacts for the remove-flat-fallback slice: the 8-dispatch plan (with the operator decision + census-balloon split recorded), the learnings ledger (mongo root-keyed no-op; FR11 scoping), and the sub-agent registry. The review log under reviews/ is gitignored. These drop at project close-out (M2). Signed-off-by: Serhii Tatarintsev <[email protected]>
The smoke test hand-types freshDb via as unknown as { sql: { user: ... } }, so
the typechecker never saw that flat sql.user is invalid on the always-qualified
postgres surface (D5b was typecheck-only). After the FR11 fail-fast, the probe
threw Unknown namespace user at runtime. Qualify the hand-typed shape and the
probe to sql.public.user, matching the rest of the demo.
Cross-example sweep for the same loosely-typed gap class (as-cast / hand-typed
flat builder access on postgres) found no other occurrences; sqlite/mongo
facet-flat access is left unchanged (correct).
Signed-off-by: Serhii Tatarintsev <[email protected]>
Signed-off-by: Serhii Tatarintsev <[email protected]>
…/facade source Signed-off-by: Serhii Tatarintsev <[email protected]>
…proxy traps Review feedback follow-up to the explicit-namespace proxy-trap change: the SQL/ORM proxies now return undefined for unknown namespace/table/model access instead of throwing. - Builder-direct test helpers return the full sql()/orm()/Db<C>/OrmClient rather than a facet alias; every call site qualifies with its namespace (db.public.users, db.public.User). - Replace throw-expecting assertions for unknown/flat access with undefined assertions. - Drop the @ts-expect-error negatives that asserted absence of the removed flat surface; keep undeclared-key/namespace guards and positives. - raw-sql-composition: type the stub context with the concrete fixture contract so db.public.users.select(...) typechecks without the hand-written builder cast; remove the cast and its comment. Signed-off-by: Serhii Tatarintsev <[email protected]>
…stead of throwing Per PR review: throwing in Proxy traps breaks external JS expectations (property probes like then/toJSON). Unknown namespace / table / model access now returns undefined; the type-level surface is still the guard (unknown access is a compile error). Drops the FR11 runtime fail-fast; removes the now-stale throw-asserting and flat-absence tests. Signed-off-by: Serhii Tatarintsev <[email protected]>
De-alias the builder/ORM helpers that returned a namespace facet (the
sql({...}).public / orm({...}).public / [UNBOUND_NAMESPACE_ID]! shortcut)
back to the full builder output, and qualify every consuming call site with
its namespace coordinate:
- preamble.ts / setup.ts / injectMigrationSqlDbSetup return Db<C> / sql(...)
/ orm(...); call sites use db.public.<table>, db().public.<table>,
orm.public.<Model>.
- value-objects (Postgres authored under __unbound__) keeps __unbound__ but
as a fully-qualified call site: ormClient[UNBOUND_NAMESPACE_ID]!.Shop.
- CLI-journey embedded scaffolds (executed via tsx) qualify db.public.user.
- Facade flat access (db.orm.<Model>, multi-namespace sql.<ns>.<table>) and
structural contract access (namespaces[...]) are left unchanged.
No production changes. Gates: pnpm build, integration-tests typecheck, and
the SQL runtime suites + CLI journeys + value-objects SQL canary all green.
Signed-off-by: Serhii Tatarintsev <[email protected]>
De-alias the e2e test helpers so they return the bare builder/orm output (Db<C> / sql(...) / orm(...)) instead of a single namespace facet. Each consuming call site now qualifies explicitly: postgres single-namespace fixtures use db.public.<table>; sqlite (unbound) uses db[UNBOUND_NAMESPACE_ID].<table> / ormClient[UNBOUND_NAMESPACE_ID].<Model>. Inline sqlite harnesses (raw-sql, verify-marker) are de-aliased the same way. Facade flat access through sqlite()/postgres() clients is unchanged. Signed-off-by: Serhii Tatarintsev <[email protected]>
… the guard Signed-off-by: Serhii Tatarintsev <[email protected]>
…d names; drop flat-access orm stub+test Signed-off-by: Serhii Tatarintsev <[email protected]>
…ration narration Signed-off-by: Serhii Tatarintsev <[email protected]>
…ing' Signed-off-by: Serhii Tatarintsev <[email protected]>
Signed-off-by: Serhii Tatarintsev <[email protected]>
…etermined Signed-off-by: Serhii Tatarintsev <[email protected]>
…erences Signed-off-by: Serhii Tatarintsev <[email protected]>
…ace Postgres emit The value-objects SQL fixture was hand-committed with the raw-interpreter shape: entities under __unbound__ on both planes. A real CLI-emitted Postgres contract binds un-namespaced authoring to the postgres default namespace public (domain: [public], storage: [__unbound__, public]), matching prisma-next-demo. Add a PSL schema + prisma-next.config.ts under the fixtures dir so the contract is generated from a real source and cannot drift, emit via the CLI, and update the SQL e2e test to qualify Shop via ormClient.public. The Mongo fixture (root-keyed __unbound__) and value-objects.integration.test.ts (raw interpreter path) are intentionally untouched. Signed-off-by: Serhii Tatarintsev <[email protected]>
…ost-0.13 bump) Signed-off-by: Serhii Tatarintsev <[email protected]>
456163a to
e4479b2
Compare
… residue) PRs #720/#778 landed the namespace-scoped front door, coordinate-keyed caches, and relation/include namespace threading. Re-scope: S1 unchanged (poly layer still base-namespace-pinned), S2 narrows to the cross-namespace polymorphic include + coverage, S3 narrows to the createCollectionRegistry remnant + MTI write + grep gate. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
…project dir The always-qualified builder / per-facade projection feature shipped in #778; only the close-out remained. - Promote the ADR draft to ADR 238. Corrected two draft errors on promotion: the qualify-flat-builder-accessors upgrade window is 0.13→0.14, and the flat facade accessor is db.<Model>. - Delete projects/explicit-namespace-dsl/. No markdown link points into it: the two supabase-integration umbrella links that did were removed with that umbrella's own close-out (#990). Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…s namespace-qualified Corrections verified against @prisma-next 0.14.0 and current main while writing the Prisma Next Fundamentals docs (prisma/web#8011): - The flat `db.orm.User` / `db.sql.user` form does not exist on Postgres. #778 removed the flat fallback; the orm() proxy resolves only namespace keys, so bare model access returns `undefined` at runtime. All Postgres examples now use `db.orm.public.<Model>` / `db.sql.public.<table>`, and the "flat form still works for single-namespace contracts" claim is replaced with the tested behavior. - `.count()` is not a collection terminal (it throws "count() is only available inside include() refinement callbacks"). Counting goes through `.aggregate((a) => ({ n: a.count() }))`; the terminal list is corrected. - SQL-builder inserts must pass rows as an array. The single-object `.insert({...})` form fails at result decoding on 0.14.0; the example now uses `.insert([{...}])` and notes the constraint. Co-Authored-By: Claude Fable 5 <[email protected]> Signed-off-by: Ankur Datta <[email protected]>
Linked issue
Refs TML-2816 (parent project TML-2550).
Builds on the additive PR for this project (the
sql.<ns>.<table>/orm.<ns>.<Model>surface added end-to-end, already onmain). This is the breaking "remove the flat fallback" half.At a glance
Before this PR, Postgres also accepted the flat
db.sql.users/db.orm.Usershape. That fallback is gone at the builder layer; on Postgres you now name the namespace.Decision
Two things ship together, and they are inseparable — the projection only does meaningful work once the flat fallback is gone:
The
sql/ormbuilder surfaces become always-qualified.Db<C>and the ORM client are namespaced-only mapped types over the contract's namespaces; the flat by-bare-name accessors (sql.<table>/orm.<Model>) and their runtime fallbacks are removed. Namespace selection is mandatory at the builder layer.Each facade projects its own default-namespace shape onto
db. A multi-namespace target (Postgres) exposes the qualified builder outputs directly. A single-namespace target (SQLite) aliasesdb.sql/db.ormto its sole-namespace facet, so flatdb.sql.users/db.orm.Userkeep working with no call-site changes. Mongo, whose ORM is keyed by model rather than namespace, was already flat and needs nothing.The mismatched-name navigation problem the project set out to solve (reaching
auth.usersvspublic.usersin one contract) is delivered; flat ergonomics for single-namespace targets are preserved purely as a facade concern. The design is captured in a draft ADR (projects/explicit-namespace-dsl/adr-draft-always-qualified-builder-surface.md).How it fits together
Cut the flat surface from the two builders.
Db<C>drops its flat-by-bare-name member and thesql()proxy's flat fallback;OrmClientdrops its flat member and theorm()proxy's bare-model path. The "tables across all namespaces" helper types are retained — they remain load-bearing generic constraints for the table proxy and query builder, so this is a member removal, not a type deletion. (packages/2-sql/4-lanes/sql-builder/src/types/db.ts, packages/3-extensions/sql-orm-client/src/orm.ts)Project per facade, statically. Each facade returns its own shape — Postgres passes the qualified builder outputs through; SQLite aliases to its
__unbound__facet fordb.sqlanddb.orm(including the transaction andpreparesurfaces). There is no shared helper and no runtime descriptor read: each facade already knows, statically, what it is. (packages/3-extensions/postgres/src/runtime/postgres.ts, packages/3-extensions/sqlite/src/runtime/sqlite.ts)Migrate every in-repo consumer. Because this is a breaking builder change, the workspace's own consumers move with it: the integration and e2e test packages and the eight example apps qualify their call sites (Postgres to
.public., SQLite builder-direct callers to the unbound facet). All single-namespace and unambiguous — a mechanical pass, verified by the type checker.Fail fast on unknown access. Accessing an unknown namespace, or an unknown table within a namespace, now throws a diagnostic that names the namespace and lists what is available — bringing the SQL builder to parity with the ORM facet's existing behavior, instead of returning a silent
undefined. Symbol access (framework probes) still returnsundefined. (packages/2-sql/4-lanes/sql-builder/src/runtime/sql.ts)Reviewer notes
feat(examples)!: qualify flat builder access in postgres example appsand the sqlite one) are the bulk of the line count. They are mechanical qualification; the type checker is the proof (a mis-qualified table is a type error). The genuinely judgment-bearing change is small: the facade projection inpostgres.ts/sqlite.tsand the two builder cuts.UnboundTables/TableNamesAcrossNamespacesare deliberately kept. They were repurposed earlier in this project to mean "tables across all namespaces" and back the table-proxy / query-builder generics. Removing the flatDb<C>member does not make them dead — don't expect them deleted.__unbound__key widens the namespace key tostring, so the facet helper insqlite.tsuses a singleblindCastwith a reason string. It's the narrowest bridge for the generic-index widening.db.orm.<Model>is already the only shape; the project's "alias to the unbound facet" framing describes a mechanism that doesn't apply to Mongo.pnpm fixtures:check(theprisma-nextCLI bin was not linked onto PATH). The drift half offixtures:checkis independently clean — the branch touches nocontract.json/contract.d.tsartifacts, and re-emitting an example produced byte-identical output.Compatibility / migration
Breaking for downstream consumers that call
sql.<table>/orm.<Model>(ordb.sql.<table>/db.orm.<Model>) directly on a multi-namespace / Postgres contract — they must qualify with the namespace. Single-namespace SQLite/Mongo facade users are unaffected. Upgrade instructions are recorded for both audiences (user, extension author). No change to emittedcontract.json/contract.d.ts.Testing performed
Run on the final HEAD:
pnpm build— clean (66 tasks).pnpm typecheck(workspace) — 0 errors (138 tasks).pnpm test:packages— 9901 passed; the 37 failures are pre-existing infra (mongodb-memory-server binary fetch + CLI subprocess-spawn timeouts), zero insql-builder/sql-orm-client/postgres/sqlite.pnpm test:integration— 890 passed; the SQL value-object round-trip canary passes; 7 failures are the same mongodb-memory-server infra.pnpm test:e2e— 109/109 green, including the multi-namespace runtime query (the cross-namespace qualification canary).pnpm lint:deps— clean.pnpm fixtures:check— blocked by the unlinked CLI bin in the sandbox; the contract-artifact diff againstmainis empty.Skill update
Upgrade-instruction entries added for the flat-accessor removal in both the user and extension-author upgrade skills (the change touches both
examples/andpackages/3-extensions/). A draft ADR for the always-qualified surface lives underprojects/explicit-namespace-dsl/; it migrates todocs/architecture docs/adrs/with a final number at project close-out.Follow-ups
Alternatives considered
defaultNamespaceId. Rejected: the discriminator is not on the runtime descriptor (it was deliberately minimised for bundle tree-shaking), so a descriptor-driven helper would have forced a framework-wide descriptor-type change. A static per-facade projection is simpler, needs no descriptor plumbing, and trivially satisfies "no per-target switch" because each facade is statically its own target.undefinedinstead.Checklist
git commit -s) per the DCO.TML-NNNN: <sentence-case title>form.Summary by CodeRabbit
Breaking Changes
Documentation
Tests