Repository navigation
TML-2790: M:N SQLite demo examples + project plan expansion (slices 4–6) - #742
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds a full ChangesPost↔Tag Many-to-Many Demo
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
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: |
16dc690 to
f3a7a5c
Compare
1e62c8e to
dbaf95a
Compare
f3a7a5c to
b772b54
Compare
e19ee4a to
074d298
Compare
b772b54 to
0f9d0c2
Compare
074d298 to
ce2608d
Compare
0f9d0c2 to
2a360f4
Compare
ce2608d to
ac1c05d
Compare
2a360f4 to
67fb93c
Compare
ac1c05d to
a5f259c
Compare
9feb292 to
facaadf
Compare
a5f259c to
9829a58
Compare
facaadf to
679770d
Compare
9829a58 to
79ebfd0
Compare
679770d to
302e804
Compare
20e4a68 to
7774dfc
Compare
302e804 to
100b1d5
Compare
7774dfc to
cef9592
Compare
100b1d5 to
91b8cc4
Compare
|
Reviewed this PR separately against |
tensordreams
left a comment
There was a problem hiding this comment.
Reviewed against projects/sql-orm-many-to-many/slices/04-sqlite-demo-examples/spec.md; ran pnpm -C examples/prisma-next-demo-sqlite typecheck and emit:check locally (both pass).
Solid, well-scoped PR: the new ORM-client modules are idiomatic and cleanly demonstrate the full M:N surface (include, some/none/every, connect/disconnect, nested create), castAs is used at branded-id boundaries with no bare as or any in the new files, the CLI wiring matches the existing command style exactly (usage errors, exit codes, JSON output), and the planning docs for slices 4–6 are internally consistent with correct ticket references. The upgrade note correctly lives only in the 0.13→0.14 cycle with no leftover in 0.12→0.13.
One issue should be resolved before merge: the newly committed migrations/app/refs/ snapshot is stale against the re-emitted contract (old canonical shape, mismatched storage hash) — see inline. Everything else is polish.
91b8cc4 to
4ea74ff
Compare
…N examples The new main baseline (TML-2605) trips the no-bare-cast ratchet on the string->branded-id casts in the M:N example helpers (+10). Replace the bare `as PostId`/`as TagId` casts with castAs<T> to keep lint:casts at delta 0. Behaviour unchanged (casts are erased at runtime). Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
… models (TML-2807 rebase) The post_tag and tag models added by this branch were emitted before main emitted SqlModelStorage.namespaceId (TML-2807); re-emit so the demo contract matches a fresh emit. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
…t<->Tag through The through descriptor now carries the junction's namespaceId; re-emit the demo contract so both M:N relations declare it. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
…r upgrade instructions The check:upgrade-coverage gate requires every PR whose diff touches examples/ to also touch the in-flight user-skill instructions. The M:N demo additions need no user-side action (additive), so no new changes[] entry — the existing array stays; this records the incidental diff. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
0.13.0 shipped without the M:N ORM-client examples, so the user-upgrade note belongs in a new 0.13→0.14 instructions directory, not the now-released 0.12→0.13 doc. The upgrade-coverage gate targets 0.13→0.14 after the release bump. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Main renamed the char(36) uuid authoring helpers to make storage explicit (field.uuid -> field.uuidString, field.id.uuidv4 -> field.id.uuidv4String). The pre-existing User/Post models were migrated on main; the M:N models added on this branch still called the old names, failing contract emit. Emitted contract is unchanged (same storage semantics, no hash drift). Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Close the two coverage gaps against the shipped M:N runtime: a reverse-
direction include (tag-posts, db.Tag.include("posts")) and connect inside
the create flow (create-post-connect-tags). Document the M:N commands in
the README, including a prose note on the required-payload junction guard,
which has no runnable example by design (the type gate makes it
uncompilable). All 9 M:N commands smoke-tested end-to-end on a fresh
database.
Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
…refs Rebase onto the slice-3 namespace change (ExecutionMutationDefault.ref now carries a namespace); regenerate the demo contract so its execution defaults match the new shape. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Slice 3 merged, so main now carries the 0.14-to-0.15 upgrade directory. With main at 0.14.0 the in-flight transition is 0.14→0.15: move the TML-2790 demo-examples note out of the released 0.13-to-0.14 cycle and into 0.14-to-0.15 (incidental, additive demo material), so the per-PR upgrade-coverage declaration lands in the directory the gate expects. Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
5822c1a to
b566f6b
Compare
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
The connect and disconnect ORM-client examples issued a mutation followed by a separate include read-back. The nested-mutation update path already reloads the parent row through the read dispatch honoring the configured `.include()`, so chaining `.include()` before `.update()` returns the post with its tags in one query. Verified: SQLite demo typecheck, lint, and emit:check pass; ran the connect and disconnect commands against a seeded DB and confirmed the returned post carries its ordered, id+label-projected tags. Claude-Session: https://claude.ai/code/session_01XcWuDhwCq2tXf5W4Py1Mk6 Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/prisma-next-demo-sqlite/src/main.ts (1)
25-41: ⚡ Quick winRemove the duplicated command catalog comment block from this TS file.
This section duplicates runtime usage/help content and will drift over time; the command behavior is already self-documenting via handlers and usage output.
As per coding guidelines,**/*.{ts,tsx,js,jsx,mts,mjs}: "Don't add comments if avoidable, prefer code that expresses its intent."🤖 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 `@examples/prisma-next-demo-sqlite/src/main.ts` around lines 25 - 41, The comment block describing the command catalog (lines 25-41) in the main.ts file duplicates runtime usage documentation and will drift over time as the code evolves. According to coding guidelines, avoid comments when code can be self-documenting. Remove the entire multi-line comment block that describes the Many-to-many commands, tag-related operations, and other command descriptions, as the actual command behavior is already documented through the handlers and runtime usage output in the code.Source: Coding guidelines
🤖 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 `@examples/prisma-next-demo-sqlite/README.md`:
- Around line 36-43: Add runnable command examples for the missing filter
variants in the "Many-to-many (ids are printed by the seed)" section of the
README.md file. After the existing `posts-with-tag-some typescript` example
line, insert two additional command lines following the same format to
demonstrate the `posts-with-tag-none` and `posts-with-tag-every` filters, using
the pattern: SQLITE_PATH=./demo.db pnpm start -- <command-name> <argument>. This
ensures all three supported filter variants (some, none, every) are documented
as runnable examples.
---
Nitpick comments:
In `@examples/prisma-next-demo-sqlite/src/main.ts`:
- Around line 25-41: The comment block describing the command catalog (lines
25-41) in the main.ts file duplicates runtime usage documentation and will drift
over time as the code evolves. According to coding guidelines, avoid comments
when code can be self-documenting. Remove the entire multi-line comment block
that describes the Many-to-many commands, tag-related operations, and other
command descriptions, as the actual command behavior is already documented
through the handlers and runtime usage output in the code.
🪄 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: ba5e4fc7-c3c8-4154-a9a7-37f690dc9393
⛔ Files ignored due to path filters (7)
projects/sql-orm-many-to-many/plan.mdis excluded by!projects/**projects/sql-orm-many-to-many/slices/04-sqlite-demo-examples/spec.mdis excluded by!projects/**projects/sql-orm-many-to-many/slices/05-psl-many-to-many-authoring/plan.mdis excluded by!projects/**projects/sql-orm-many-to-many/slices/05-psl-many-to-many-authoring/spec.mdis excluded by!projects/**projects/sql-orm-many-to-many/slices/06-pg-demo-examples/plan.mdis excluded by!projects/**projects/sql-orm-many-to-many/slices/06-pg-demo-examples/spec.mdis excluded by!projects/**projects/sql-orm-many-to-many/spec.mdis excluded by!projects/**
📒 Files selected for processing (14)
examples/prisma-next-demo-sqlite/README.mdexamples/prisma-next-demo-sqlite/prisma/contract.tsexamples/prisma-next-demo-sqlite/scripts/seed.tsexamples/prisma-next-demo-sqlite/src/main.tsexamples/prisma-next-demo-sqlite/src/orm-client/connect-post-tags.tsexamples/prisma-next-demo-sqlite/src/orm-client/create-post-connect-tags.tsexamples/prisma-next-demo-sqlite/src/orm-client/create-post-with-tags.tsexamples/prisma-next-demo-sqlite/src/orm-client/disconnect-post-tags.tsexamples/prisma-next-demo-sqlite/src/orm-client/get-post-tags.tsexamples/prisma-next-demo-sqlite/src/orm-client/get-posts-by-tag-filter.tsexamples/prisma-next-demo-sqlite/src/orm-client/get-tag-posts.tsexamples/prisma-next-demo-sqlite/src/prisma/contract.d.tsexamples/prisma-next-demo-sqlite/src/prisma/contract.jsonskills/upgrade/prisma-next-upgrade/upgrades/0.14-to-0.15/instructions.md
The runnable command list showed only `posts-with-tag-some`, while the CLI dispatches `-some`, `-none`, and `-every` and the runtime usage string already lists all three. Add the two missing lines so the README matches the implemented commands. Claude-Session: https://claude.ai/code/session_01XcWuDhwCq2tXf5W4Py1Mk6 Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
|
Thanks! Addressed the README finding (087a437). On the main.ts nitpick — keeping the top-of-file command catalog. This is a demo entry point where an at-a-glance map of every command is deliberately pedagogical, and a human reviewer already signed off on it. I take the drift point (the README list had in fact gone stale), but the fix there is to keep the docs current rather than drop the in-file overview, so I'm leaving the comment block as-is. |
…rough) (prisma#819) **Slice 5 of the [SQL ORM: Many-to-Many End to End](https://linear.app/prisma-company/project/sql-orm-many-to-many-end-to-end-c178df40ca3a) project** (follow-on group). Refs TML-2794. > **Stacked PR** — base is `tml-2790-mn-demo-examples` (prisma#742, slice 4); below that `tml-2787-slice-3-write` (prisma#683) → `main`. ## Overview PSL could not author a navigable many-to-many relation: the relation resolver emitted only `N:1`/`1:N`, and a bare list field (`tags Tag[]`) with no FK pair was diagnosed as `PSL_ORPHANED_BACKRELATION_LIST` — `cardinality: 'N:M' + through` existed only via the TS contract builder. This PR teaches the PSL interpreter **explicit-junction recognition** (form 1, pinned at pickup): when a bare list field has a recognisable junction model — composite `@@id([a, b])` covering exactly the FK columns of two `N:1` relations to the two side models — the list lowers to a navigable `N:M` relation through that junction, shape-identical to `rel.manyToMany` output. ## Changes - `psl-relation-resolution.ts`: junction recognition in the previously-orphaned branch — `findJunctionFkPairs` + id-coverage gate + `manyToManyRelationNode`; child FK must reference the target's **full id** (set-equal), `through.childColumns` reordered to id order (the runtime joins `childColumns[i] = targetColumns[i]` by index); decline → existing orphaned diagnostic. Self-referential M:N disambiguated by the list's `@relation` name (pins the parent-side FK); unnamed symmetric lists get the ambiguity diagnostic. Surrogate-id join models are deliberately not recognised. Direct FK matches still win (stay `1:N`). - 10 lowering unit tests (`interpreter.relations.many-to-many.test.ts`): both directions, composite keys, swapped-order FK references, self-referential, diagnostic preservation, `validateContract` round-trip. - PSL-authored integration fixture `fixtures/mn-psl/` (`User ↔ Tag` via `user_tags`, mirroring the TS fixture) wired into the sql-orm-client emit pipeline so `fixtures:check` regenerates and diffs it. - `mn-psl-parity.test.ts`: 8 integration tests proving the full M:N ORM API (include explicit+implicit, `some`/`none`/`every`, connect, disconnect, nested create) against the PSL-emitted contract. ## Why The PG demo emits its contract from PSL, so it cannot show the M:N API until PSL can author it (slice 6 is blocked on this). Form 1 was chosen over Prisma-style implicit lists as the smallest surface that matches the existing diagnostic's guidance; implicit lists remain a clean follow-up. ## Scope PSL authoring layer + fixtures/tests only. No sql-orm-client runtime changes, no TS-builder changes, no demo changes (slice 6). Implicit-list authoring (form 2) deliberately excluded. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved many-to-many backrelation lowering via explicit junction models, including composite-key support and correct through/column ordering. * Enhanced FK/backrelation metadata to improve many-to-many resolution across namespaces. * **Bug Fixes / Improvements** * Added richer diagnostics for orphaned, ambiguous, and invalid many-to-many junction scenarios. * Strengthened full SQL contract validation for N:M through configurations (pairing, referenced column existence, and storage-type consistency). * **Tests** * Added unit tests for many-to-many lowering and diagnostics. * Added integration parity coverage for includes, filters, and nested writes using the mn-psl fixture. * **Documentation / Chores** * Updated Prisma Next emit flow and refreshed mn-psl fixture typing for UUID-style IDs. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Alexey Orlenko's AI Agent <[email protected]>
Follow-on to the SQL ORM: Many-to-Many End to End project: M:N demo examples + the project-plan expansion they surfaced.
SQLite demo M:N examples (
72ef8b793,883309ecc)The SQLite demo (
examples/prisma-next-demo-sqlite, TS-authored) now demonstrates the full M:N ORM API via a purePost ↔ Tagjunction (PostTag):get-post-tags—.include(tags, t => t.select(...)).get-posts-by-tag-filter—.where(p => p.tags.some/none/every(t => t.label.eq(...))).connect-post-tags/disconnect-post-tags/create-post-with-tags—.update/.create({ tags: t => t.connect/disconnect/create([...]) })with readback.Wired as 6 CLI commands + seed; smoke-tested end-to-end (SQLite is offline-runnable); emitted contract carries
cardinality:N:M+through;emit:check+ typecheck clean.Why only SQLite (and the plan expansion) (
d711adfb6)Adding examples surfaced a real gap: the navigable M:N API is authorable only via the TS contract builder (
rel.manyToMany), not PSL — PSL emits only1:N/N:1and routes M:N to explicit junction models. The PG demo emits from PSL, so it cant show M:N until PSL learns to author it. So:Scope / notes
This PR ships the SQLite examples + the planning docs only. PG demo examples + PSL authoring are tracked (TML-2794/2795) and specd but not implemented here. No production
src/changes — demo + project-docs only.Refs: TML-2790.
Summary by CodeRabbit
Release Notes
New Features
Post↔Tagmany-to-many tagging via a junction.some/none/every), and connect/disconnect or create posts with tags.Documentation