Skip to content

TML-2790: M:N SQLite demo examples + project plan expansion (slices 4–6)#742

Open
tensordreams wants to merge 7 commits into
tml-2787-slice-3-writefrom
tml-2790-mn-demo-examples
Open

TML-2790: M:N SQLite demo examples + project plan expansion (slices 4–6)#742
tensordreams wants to merge 7 commits into
tml-2787-slice-3-writefrom
tml-2790-mn-demo-examples

Conversation

@tensordreams
Copy link
Copy Markdown
Contributor

Supersedes #697 — that PR was auto-marked merged by GitHub when a botched force-push briefly made its head identical to its base (nothing was actually merged; the branch content is unchanged). Same commits, same review state.

Follow-on to the SQL ORM: Many-to-Many End to End project: M:N demo examples + the project-plan expansion they surfaced.

Stacked PR — top of the M:N stack: tml-2787 (#683) → … → tml-2729 (#667) → main (the whole stack is rebased onto the latest main).

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 pure Post ↔ Tag junction (PostTag):

  • Read: get-post-tags.include(tags, t => t.select(...)).
  • Filter: get-posts-by-tag-filter.where(p => p.tags.some/none/every(t => t.label.eq(...))).
  • Write (callback mutator): 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 only 1:N/N:1 and 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:

  • Filed TML-2794 — PSL many-to-many authoring (the framework gap).
  • Filed TML-2795 — PG demo M:N examples + pre-existing dual-mode contract drift (blocked by TML-2794).
  • Amended the project spec + plan with follow-on slices 4–6 (SQLite examples [done], PSL M:N authoring [planned], PG demo [planned]) + slice specs/plans. Slice 5 is framework-scoped and flagged for possible promotion to its own project.

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.

Adds Tag model, PostTag junction (composite PK post_tag_pkey), and
rel.manyToMany() declarations on both Post.tags and Tag.posts.
Re-emits contract.json / contract.d.ts; cardinality 'N:M' + through
descriptor present in the generated artifacts.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Adds five ORM client modules exercising the Post↔Tag N:M relation:
- get-post-tags: .include('tags', ...) — include read across junction
- get-posts-by-tag-filter: .some()/.none()/.every() on N:M relation
- connect-post-tags: update + t.connect([{id}]) callback mutator
- disconnect-post-tags: update + t.disconnect([{id}]) callback mutator
- create-post-with-tags: create + t.create([...]) nested mutation

Seed extended with Tag rows + junction rows (typescript/orm/demo tags
linked to First Post and Second Post). CLI commands registered in
main.ts. Migration refs committed for offline db:init reproducibility.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Spec + plan amended for the follow-on scope (demos + authoring completeness):
slice 4 SQLite demo examples (done, TML-2790), slice 5 PSL M:N authoring
(TML-2794, framework gap — may promote to its own project), slice 6 PG demo
examples + dual-mode reconciliation (TML-2795, blocked by slice 5). Slice
specs + provisional dispatch plans for each.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
…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 <robot@aqrln.net>
… 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 <robot@aqrln.net>
…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 <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
@tensordreams tensordreams requested a review from a team as a code owner June 5, 2026 15:04
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 5, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 105fa815-16d7-433b-92d9-30b07df3b6a7

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-2790-mn-demo-examples

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

size-limit report 📦

Path Size
postgres / no-emit 146.17 KB (0%)
postgres / emit 118.09 KB (0%)
mongo / no-emit 76.04 KB (0%)
mongo / emit 70.89 KB (0%)
cf-worker / no-emit 174.84 KB (0%)
cf-worker / emit 143.55 KB (0%)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 5, 2026

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 1e62c8e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant