Skip to content

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

Open
tensordreams wants to merge 4 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)#697
tensordreams wants to merge 4 commits into
tml-2787-slice-3-writefrom
tml-2790-mn-demo-examples

Conversation

@tensordreams
Copy link
Copy Markdown
Contributor

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.

@tensordreams tensordreams requested a review from a team as a code owner June 2, 2026 13:47
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 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: 8a28b076-9043-4ae2-b814-87f483002cf9

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 2, 2026

size-limit report 📦

Path Size
postgres / no-emit 138.5 KB (0%)
postgres / emit 110.08 KB (0%)
mongo / no-emit 75.78 KB (0%)
mongo / emit 70.78 KB (0%)
cf-worker / no-emit 166.36 KB (0%)
cf-worker / emit 134.55 KB (0%)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 2, 2026

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: c1c88d2

@tensordreams tensordreams force-pushed the tml-2790-mn-demo-examples branch from d711adf to 5ad3cff Compare June 3, 2026 08:51
@tensordreams tensordreams force-pushed the tml-2787-slice-3-write branch from 3e1c908 to 308b48d Compare June 3, 2026 08:51
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>
@tensordreams tensordreams force-pushed the tml-2790-mn-demo-examples branch from bd25a3c to c1c88d2 Compare June 3, 2026 11:32
@tensordreams tensordreams force-pushed the tml-2787-slice-3-write branch from 308b48d to bb3e246 Compare June 3, 2026 11:32
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