Skip to content

TML-2795: M:N slice 6 — PG demo M:N examples + PSL-only contract source#820

Open
tensordreams wants to merge 8 commits into
tml-2794-slice-5-psl-mn-authoringfrom
tml-2795-slice-6-pg-demo-mn-examples
Open

TML-2795: M:N slice 6 — PG demo M:N examples + PSL-only contract source#820
tensordreams wants to merge 8 commits into
tml-2794-slice-5-psl-mn-authoringfrom
tml-2795-slice-6-pg-demo-mn-examples

Conversation

@tensordreams

Copy link
Copy Markdown
Contributor

Slice 6 (final) of the SQL ORM: Many-to-Many End to End project. Refs TML-2795.

Stacked PR — base is tml-2794-slice-5-psl-mn-authoring (#819, slice 5); below that tml-2790-mn-demo-examples (#742) → tml-2787-slice-3-write (#683) → main.

Overview

Two halves, per the slice spec:

A. Dual-mode reconciliation → PSL-only. The PG demo was nominally dual-mode (PSL + TS contract sources expected to emit identically), but the TS leg had drifted — the TS builder cannot author the discriminated Task/Bug/Feature hierarchy, so test:dual-mode was red. This PR resolves it via the spec's option (ii): the TS contract source is removed and PSL becomes the single source. That removal necessarily took the no-emit workflow with it (it exists only to showcase the TS-authored contract) — decision and coverage notes recorded in the project's unattended-decisions log. After slice 5, PSL is strictly the more capable authoring surface for this demo: it authors both the discriminator hierarchy and M:N, neither of which the TS builder can express.

B. M:N examples. Post ↔ Tag M:N authored in PSL using slice 5's explicit-junction form (composite-@@id PostTag + bare lists both sides), with a properly chained 6-op migration (20260612T1945_add_post_tags — tag + junction tables, composite PK, FK indexes/FKs; not a re-baseline). All nine M:N surfaces from the SQLite demo are mirrored as repo-* CLI commands: include both directions, some/none/every filters (vacuous-truth every observable via an untagged seed post), connect, disconnect, nested create, and connect-in-create. Seed adds tags + junction rows; README documents the commands and the required-payload-guard behavior.

Tests

8 PGlite-backed integration tests (test/many-to-many.integration.test.ts) per the project standard: whole-shape toEqual, explicit select in most reads plus one implicit default-selection include, all three filter predicates, and include-readback after each of the four write kinds. Full demo suite: 9 files / 59 tests. Root fixtures:check and typecheck:examples green.

Scope

examples/prisma-next-demo only — no framework, PSL-interpreter, or sql-orm-client changes (slice 5 needed no fixes to support this). With this slice, the M:N API is demonstrated in both demos and the project's follow-on scope is complete.

The no-emit CLI, its queries, and the TS-leg test files all consume the
TypeScript contract source, which is being dropped in favour of the
canonical PSL source (the demo becomes PSL-only). The emit-side suite
already covers the enum type surface (test/demo-dx.types.test.ts); the
runtime enum-surface integration coverage leaves with the TS leg.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
…urce

The TS-builder contract had drifted from the canonical PSL source (no
discriminated Task/Bug/Feature hierarchy, no displayName, untyped
address), keeping the dual-mode emit comparison permanently red on the
TS leg. The demo now emits exclusively from src/prisma/contract.prisma:
the TS emit config, the emit:ts/emit:psl/test:dual-mode scripts, and the
@prisma-next/sql-contract-ts dependency are removed.

The pnpm-lock.yaml @vitest/coverage-v8 peer-suffix churn is mechanical
pnpm install re-resolution output.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Adds a Tag model and a PostTag explicit-junction model (composite @@id
over the two FK columns, two @relation N:1s) plus bare list fields on
both sides, so the PSL interpreter lowers the pair to navigable N:M
relations with a populated through descriptor. Re-emits the contract
artifacts and extends the app migration chain with the planned
tag/post_tag delta (tables, FK indexes, foreign keys).

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
Mirrors the SQLite demo M:N surfaces in the PG demo conventions:
include in both directions (repo-post-tags, repo-tag-posts),
some/none/every relation filters (repo-posts-with-tag-*), and nested
connect/disconnect/create writes through the callback mutator
(repo-connect-post-tags, repo-disconnect-post-tags,
repo-create-post-with-tags, repo-create-post-connect-tags). The seed
gains three tags and junction rows (third post stays untagged so the
every filter is observable), and the README documents the commands
plus the required-payload junction guard.

Signed-off-by: Alexey Orlenko's AI Agent <robot@aqrln.net>
One focused file in the demo test pattern (withDevDatabase +
initTestDatabase): whole-row include readback after connect,
disconnect, and both create flows; explicit selects in most reads
plus one implicit default-selection include; and some/none/every
filter coverage including the vacuous-truth every case on an
untagged post.

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 12, 2026 20:17
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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: e2b9029a-9505-492a-8be1-7de78da91821

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-2795-slice-6-pg-demo-mn-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.

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/extension-supabase

npm i https://pkg.pr.new/@prisma-next/extension-supabase@820

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 8d27a89

@github-actions

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 156.34 KB (0%)
postgres / emit 123.64 KB (0%)
mongo / no-emit 76.92 KB (0%)
mongo / emit 71.01 KB (0%)
cf-worker / no-emit 183.82 KB (0%)
cf-worker / emit 147.7 KB (0%)

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