Repository navigation
Conversation
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (4)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
72db66a to
291bb99
Compare
90cf526 to
669c230
Compare
669c230 to
433e9bb
Compare
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/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: |
Shape the end-to-end many-to-many project: spec + 4-slice plan (0 contract+resolver foundation, gating parallel read/filter/write). Promoted from TML-2597 to a dedicated Linear Project; slices TML-2784..2787. No code changes — planning artifacts only. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
433e9bb to
c350460
Compare
…risma#679) Slice 1 of the **SQL ORM: Many-to-Many End to End** project ([Linear project](https://linear.app/prisma-company/project/sql-orm-many-to-many-end-to-end-c178df40ca3a)). Reads an M:N relation through its junction. > **Stacked PR.** Base is `tml-2784` (prisma#678, slice 0) → `tml-2597` (prisma#673) → `tml-2729` (prisma#667) → `main`. Review/merge bottom-up. ## Overview `db.orm.User.include(tags)` now resolves a many-to-many relation to `{ …user, tags: Tag[] }` in a **single correlated subquery** that walks parent → junction → target — no `LATERAL`, no second query. Built on slice 0s `ResolvedRelation.through`. ## Changes (4 commits) - **`fcecac5b3`** — integration fixture gains a `User ↔ Tag` M:N relation via a `UserTag` junction (composite PK `user_id`/`tag_id`); `contract.json`/`.d.ts` re-emitted. - **`e587b433c`** — read path: `IncludeExpr.through` (surfaced by `resolveIncludeRelation`), and `buildCorrelatedIncludeProjection` gains an M:N branch — `buildManyToManyJunctionArtifacts` builds a non-LATERAL inner join to the junction (`junction.childColumns = target.targetColumns`) correlated to the parent (`junction.parentColumns = parent` anchor), composite-key AND-ed; FK decode path reused. Unit-tested at the AST level. - **`b9c3e9f7b`** — replace 2 bare `as` casts with `castAs`; add the missing M:N + distinct + non-leaf unit test. - **`d3232cbad`** — 7 integration tests (PGlite). ## Integration tests (per the project standard) Whole-row `toEqual`; 6/7 use explicit `.select(...)` (so adding a model field wont churn assertions); **test 5 uses implicit/default selection** (full `User` + `tags: Tag[]` shape); a **single-execution / no-`LATERAL`** assertion; depth-2 nesting (`invitedUsers → tags`); edges (user with no tags → `tags: []`; a tag shared by multiple users). ## Why This is the first of the three relation-shaped M:N consumers (read / filter / write) over slice 0s shared `through` primitive. The correlated-only approach matches the post-TML-2729 read path (no LATERAL to reintroduce). ## Scope / notes Read only — filter (TML-2786) and write (TML-2787) are later slices. The fixture is **one-directional** (`User.tags`; reverse `Tag.users` deferred — adding it trips a latent create-overload type fragility in unrelated mutation-defaults tests; see the projects unattended-decisions log). Fixture re-emit used a `tsx` bypass because the CLI `contract emit` fails on a sandbox config-load env issue — **CI `fixtures:check` is the real golden-stability gate**; please confirm its green (or re-run the canonical emit). Broad integration runs show pre-existing PGlite/WASM JIT flakiness; the M:N tests pass on targeted runs. Refs: TML-2785. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * include(...) now supports many-to-many (M:N) relationships via junction tables, returning correct nested arrays and preserving single-query execution. * **Tests** * Added unit and integration tests covering M:N includes, composite keys, nested includes, distinct+nested scenarios, and end-to-end result shape correctness. * **Documentation** * Added upgrade notes for 0.14 describing the runtime support for M:N correlated include reads. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
…e junction (prisma#680) Slice 2 of the **SQL ORM: Many-to-Many End to End** project ([Linear project](https://linear.app/prisma-company/project/sql-orm-many-to-many-end-to-end-c178df40ca3a)). Filters an M:N relation through its junction. > **Stacked PR.** Base is `tml-2785` (prisma#679, slice 1) → `tml-2784` (prisma#678) → `tml-2597` (prisma#673) → `tml-2729` (prisma#667) → `main`. Review/merge bottom-up. ## Overview `db.orm.User.filter((u) => u.tags.some/every/none((t) => …))` now emits an EXISTS / NOT EXISTS subquery that walks the `UserTag` junction. Previously `buildJoinWhere` read only `relation.on.localFields/targetFields`, so an M:N filter produced a wrong-shape EXISTS that skipped the junction. ## Changes (2 commits) - **`f9226ccb9`** — `model-accessor.ts`: `buildManyToManyExistsExpr` builds the two-sided junction correlation — junction→target (`through.childColumns = target.targetColumns`) and junction→parent (`through.parentColumns = parent.{on.localFields resolved}`, mirroring slice 1s read correlation), composite-key AND-ed. Shapes: `some`=`EXISTS`, `none`=`NOT EXISTS`, `every`=`NOT EXISTS(… AND NOT(pred))`, vacuous `every({})`=`AndExpr.true()` (consistent with the FK `every` path). Dispatch via a `hasThrough` **type predicate** (no bare cast). 6 AST unit tests. - **`e65a9db43`** — 9 integration tests (PGlite). ## Integration tests (per the project standard) Whole-row `toEqual` on the **filtered user set**; 8/9 use explicit `.select`; **test 6 uses implicit/default selection**. Covers `some`, `none`, `every` (incl. the vacuous tag-less-user-qualifies case, tested in isolation and alongside partial-match exclusion), and empty-match edges for all three operators. ## Why Second of the three relation-shaped M:N consumers over slice 0s shared `through` primitive. The filter correlation mirrors slice 1s read correlation for consistency. ## Scope / notes Filter only — write (TML-2787) is the last slice. No fixture change (reuses slice 1s `User ↔ Tag` + its seed helpers). No production change in the test dispatch. Broad integration runs show pre-existing PGlite/WASM JIT flakiness (logged); the M:N filter tests pass on targeted runs. Refs: TML-2786. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Many-to-many relation filters now supported: use tags.some(...), tags.none(...), and tags.every(...) on M:N relations with correct EXISTS/NOT EXISTS semantics. * **Tests** * Added unit and integration tests covering M:N filters, composite-key and self-referential joins, vacuous-every behavior, and error cases for invalid junction metadata. * **Documentation** * Upgrade notes updated to mention M:N relation filter support. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Slice 3 (final) of the **SQL ORM: Many-to-Many End to End** project ([Linear project](https://linear.app/prisma-company/project/sql-orm-many-to-many-end-to-end-c178df40ca3a)). Nested `connect`/`disconnect`/`create` through the junction + the required-payload safety rail. > **Stacked PR.** Base `tml-2786` (prisma#680) → `tml-2785` (prisma#679) → `tml-2784` (prisma#678) → `tml-2597` (prisma#673) → `tml-2729` (prisma#667) → `main`. Review/merge bottom-up. ## Overview `db.orm.User.update/create({ tags: (t) => t.connect/disconnect/create(...) })` now routes to the `UserTag` junction (INSERT / DELETE / target-insert+link), under both `create()` and `update()`. The `N:M not supported yet` guard is gone. Junctions with a **required non-FK payload column** cant be written through the sugar, so `create` **and** `connect` on them are disabled at both the type level and runtime with a clear error (disconnect stays). ## Changes - **Runtime junction write path:** `partitionByOwnership` gains a `junctionOwned` bucket (keyed on `through` presence); connect→INSERT, disconnect→DELETE, create→target-insert+link, both flows, composite-key AND-ed; the rejection unit test flipped positive. (`getRelationDefinitions` now carries `through`.) - **Required-payload fixture:** `User ↔ Role` via `UserRole(user_id, role_id, level NOT NULL)` (canonical CLI emit). - **Runtime guard:** nested `create` **and** `connect` on a required-payload junction throw (connect also INSERTs a junction row it cant complete → DB NOT-NULL violation). Disconnect stays allowed. - **Type-level gate:** `HasRequiredJunctionPayload` + `HasJunctionThrough` compose `LinkWritesDisabled` and `BareDisconnectDisabled` on `RelationMutator`, disabling `create`/`connect` and bare `disconnect()` at the type level for required-payload junctions. The `.d.ts` emitter now carries `through` (namespace-scoped), so the gate derives required-payload columns from the junction model's field types without `any`. Covered by type tests (`junction-link-write-disable.test-d.ts`). - **Error handling:** `isUniqueConstraintViolation` uses driver-normalized `SqlQueryError.sqlState`; duplicate-connect wraps with a domain error naming the junction; shared-column conflicts detected on both INSERT and DELETE sides; metadata-length assertions fail fast; preflight detects duplicate resolved targets. - **Namespace scoping:** `MutationDefaultsOptions` carries `namespace`; `ModelNameForTable` and `JunctionPayloadFieldNames` are namespace-aware; execution-default and storage-default columns are excluded from `requiredPayloadColumns`. - **Transaction safety:** ORM mutations run inside a transaction via `withMutationScope`. ## Integration tests (per the project standard) `mn-nested-write.test.ts` — connect/create/disconnect on the pure `User.tags` junction and the required-payload `User.roles` junction, both `create()` and `update()` flows; duplicate-connect rejection; missing-target rejection; parent-insert-failure-after-connect-preflight (no partial writes); execution-defaulted junction payload column; bare `disconnect()` type error on junctions; whole-row `toEqual`, explicit `.select` in most, ≥1 implicit/default selection. ## AC status - ✅ **AC-1** — connect/disconnect/create route to junction DML, both flows, guard removed, rejection test flipped (unit + integration). - ✅ **AC-2** — Runtime disable of `create`+`connect` on required-payload junctions + type-level disable (`create`/`connect` → `never`, bare `disconnect()` → type error on junctions). Both implemented and tested. - ✅ **AC-3** — write integration tests per the standard. ## Notes `connect`-disabled-on-required-payload was a mid-flight spec correction (the original spec wrongly assumed connect was FK-pair-only safe). Duplicate `connect` errors deliberately rather than silently succeeding (intentional divergence from Prisma-classic implicit-M:N `connect`, which is idempotent via `ON CONFLICT DO NOTHING`). The reverse `Tag.users`/`Role.users` directions are deferred (one-directional fixture, decision prisma#3). Refs: TML-2787. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enabled many-to-many nested mutations via junction tables when junction metadata is available, including `create`, `connect`, and `disconnect`. * Added compile-time and runtime protections to prevent creating/connecting junction links when the junction has required payload fields. * **Bug Fixes** * Improved unique-constraint error detection for more consistent handling (based on SQLSTATE). * **Tests** * Expanded unit and integration coverage for junction-based M:N nested writes, junction payload validation, and correct junction DML behavior. * **Chores** * Updated generated contract and example artifacts to use namespace-qualified execution-default references. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Shaping artifacts for the SQL ORM: Many-to-Many End to End project. No code changes —
projects/sql-orm-many-to-many/only (spec, plan, README, trace).What this adds
spec.md— system-level intent: restore the relation-shaped ORM API (include / filter / nested write) over M:N, so users stop hand-wiring explicit junction models and the Pothos plugin stops rejecting M:N at build.plan.md— 4 slices: slice 0 (contract + resolver foundation) gates a parallel fan-out of read / filter / write.Key decisions captured
cardinality: N:Mand the undeclaredthroughkey. Slice 0 closes that; it is a real gap, not prep.throughdescriptor on the single shared resolver, consumed three ways (not junction-as-nested-include, which does not generalise to filter/write).connect/disconnect/create); nestedupdate/upsert/delete/setare out of scope → TML-2781.Linear
Promoted from TML-2597 to a dedicated Linear Project (SQL ORM: Many-to-Many End to End). Slices: TML-2784 (0) / TML-2785 (1) / TML-2786 (2) / TML-2787 (3).
Scope statement
Planning artifacts only. No package code, no fixtures, no behavior change. Refs: TML-2597.