Skip to content

TML-3168: Return affected write counts without pre-SELECT - #29921

Merged
SevInf merged 82 commits into
mainfrom
tml-3168-count-terminals
Aug 12, 2026
Merged

TML-3168: Return affected write counts without pre-SELECT#29921
SevInf merged 82 commits into
mainfrom
tml-3168-count-terminals

Conversation

@StevenMcClankerton

@StevenMcClankerton StevenMcClankerton commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-3168

Prerequisite: #29907 provides the driver-level query() / execute() split consumed here.

At a glance

const count = await users.where({ name: 'Stale' }).updateAndCount({ name: 'Updated' });
expect(count).toBe(2);
expect(observedStatements).toHaveLength(1);

This real integration case now gets the count from the single UPDATE; previously the terminal selected matching rows before writing.

Summary

Count-returning writes now report the database's affected-row result from the write itself, closing the race and extra round trip created by a pre-SELECT. The runtime hard cut makes row queries and statistics execution explicit all the way through middleware and bound scopes.

Decision

This PR ships two connected changes:

  1. Runtime callers explicitly choose query() / queryPrepared() for rows or execute() for statement statistics, with operation-discriminated middleware results.
  2. SQL updateAndCount and deleteAndCount execute one non-returning write and return stats.affectedRows, while Mongo preserves its native modified/deleted count semantics through the same vocabulary.

Reviewer notes

  • The large mechanical fan-out is deliberate: this is a compatibility-free runtime vocabulary hard cut, so examples, fakes, integrations, Mongo, SQL, and Supabase callers migrate together.
  • Middleware rejects a query result offered to execute() or statistics offered to query(); it never converts row length into affectedRows.
  • updateAndCount({}) remains a zero-statement no-op.
  • Counts remain target-native rather than normalized: Mongo updates use modifiedCount; SQL uses each driver's affected-row source.
  • Contract entities, capabilities, contract.json, and contract.d.ts are unchanged.
  • The package and integration aggregate commands remain locally red only in unrelated CLI timeout tests; affected package suites, typecheck, E2E, fixtures, and focused integration coverage are green.

How it fits together

  1. The shared runtime contract separates streaming rows from eager statement statistics in runtime-middleware.ts and runtime-scope.ts.
  2. Runtime middleware carries an operation discriminant through interception and completion, preserving cancellation, codecs, telemetry, fresh execution IDs, and lifecycle hooks for both paths.
  3. SQL connection and transaction scopes, Mongo runtime, and Supabase role-bound scopes route each operation to the already-split driver surface from TML-3167: Split SQL query and execute driver SPI #29907 without losing connection binding or cleanup behavior.
  4. The ORM count terminals in collection.ts compile one non-returning DML plan, call execute(), and return the driver's affectedRows unchanged.

Behavior changes & evidence

Compatibility / migration / risk

This is a deliberate public runtime hard cut: row consumers must use query() / queryPrepared(), and execute() now means statistics. Upgrade instructions are recorded in skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/ and skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/. There are no contract artifact or capability changes. The principal risk is missed callers across the broad migration; public type tests, focused package suites, integrations, and E2E coverage exercise the migrated surfaces.

Testing performed

  • pnpm typecheck — 165/165 workspace tasks passed.
  • pnpm lint:deps — 1,921 modules and 2,934 dependencies passed.
  • pnpm test:e2e — 20 files and 112 tests passed.
  • pnpm fixtures:check — passed with no tracked fixture delta.
  • Affected framework, SQL runtime, SQL ORM, Mongo, Supabase, cache, example, and focused integration suites passed; the final React Router correction passed typecheck, lint, and 2 focused tests.
  • pnpm test:packages — 14,542 tests passed; the command remained red in nine unrelated CLI tests that exceeded their 500 ms timeout.
  • pnpm test:integration — 1,819 tests passed; the command remained red in four CLI journey timeouts and one CLI cleanup-hook timeout.
  • pnpm test:examples passed all locally runnable example tasks; the Cloudflare Worker suite requires an unavailable Hyperdrive database environment.

Follow-ups

  • TML-3169 owns the broader count-semantics documentation and scorecard work.

Skill update

This public hard cut adds runtime-query-execute-hard-cut entries at:

  • skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md

Alternatives considered

  • Keep the pre-SELECT count: rejected because it adds a round trip and can become stale before the write executes.
  • Infer query versus statistics from SQL or plan shape: rejected because lowering state does not define result semantics and inference makes middleware ambiguous.
  • Add prepared statistics execution now: rejected because there is no prepared count caller; queryPrepared() covers the existing prepared row use case without speculative API surface.
  • Normalize counts across targets: rejected so Postgres/SQLite and Mongo continue to expose their engines' established affected versus modified semantics.

Checklist

  • All commits are signed off (git commit -s) per the DCO. The DCO status check will block merge if any commit is missing a Signed-off-by: trailer.
  • I read CONTRIBUTING.md and the change is scoped to one logical concern.
  • Tests are updated (or n/a if the change is doc-only / refactor with no behavioural delta).
  • The PR title is in TML-NNNN: <sentence-case title> form (Linear ticket prefix + concise title naming the concrete deliverable).
  • The Skill update section above is filled in (or stated n/a — internal only).

Summary by CodeRabbit

  • New Features

    • Separated row-returning operations (query/queryPrepared) from write execution (execute), which now reports affected-row statistics.
    • Added distinct middleware lifecycle hooks for queries and executions.
    • Improved mutation count operations to use affected-row results directly.
    • Added query support across database, connection, transaction, MongoDB, PostgreSQL, SQLite, and Supabase interfaces.
  • Documentation

    • Updated guides, examples, upgrade instructions, and error references for the revised APIs and middleware terminology.
  • Bug Fixes

    • Improved execution error preservation, cancellation handling, cleanup, and statistics validation.

@StevenMcClankerton
StevenMcClankerton requested a review from a team as a code owner August 7, 2026 11:46
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The runtime API now separates row-producing query and queryPrepared operations from statistics-returning execute operations. Frameworks, SQL and Mongo runtimes, adapters, middleware, ORM paths, examples, documentation, and tests were migrated.

Changes

Runtime query and execute split

Layer / File(s) Summary
Runtime contracts and middleware
packages/1-framework/..., packages/2-sql/4-lanes/..., packages/2-sql/5-runtime/...
Runtime interfaces now expose streaming query methods and statistics-returning execute methods. Middleware has separate query and execute hooks and result types. Prepared statements use queryPrepared.
SQL, Mongo, ORM, and Supabase implementations
packages/2-mongo-family/..., packages/3-extensions/...
Runtime implementations route row operations through query paths and write statistics through execute paths. Mongo and ORM count operations use affectedRows.
Tests, examples, and migration guidance
test/..., examples/..., skills/..., docs/...
Call sites, fakes, type tests, integration tests, documentation, and upgrade instructions use the separated APIs. Write-only operations retain direct execute calls.
Supporting driver and configuration updates
packages/3-targets/..., apps/..., scripts/...
Driver tests cover streaming and connection behavior. Telemetry, lint configuration, and related examples reflect the new execution contracts.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant Runtime
  participant Middleware
  participant Driver
  Caller->>Runtime: query(plan)
  Runtime->>Middleware: Run query lifecycle
  Middleware->>Driver: Stream rows
  Driver-->>Caller: AsyncIterableResult<Row>
  Caller->>Runtime: execute(plan)
  Runtime->>Middleware: Run execute lifecycle
  Middleware->>Driver: Execute statement
  Driver-->>Caller: RuntimeStatementStats
Loading

Possibly related issues

  • prisma/prisma-next#648 — Both changes update the runtime execution path used by serverless and marker-verification flows.

Possibly related PRs

  • prisma/prisma#29907 — It modifies the same query/execute separation across runtime, driver, prepared-statement, and test APIs.

Suggested labels: lgtm

Suggested reviewers: aqrln

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the affected-row count change and removal of the pre-SELECT, which are central objectives of the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch tml-3168-count-terminals
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-3168-count-terminals

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

prisma-next

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

@prisma/orm-extension-arktype-json

npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@29921

@prisma/orm-extension-middleware-cache

npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@29921

@prisma/orm-extension-paradedb

npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@29921

@prisma/orm-extension-pgvector

npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@29921

@prisma/orm-extension-postgis

npm i https://pkg.pr.new/@prisma/orm-extension-postgis@29921

@prisma/orm-extension-supabase

npm i https://pkg.pr.new/@prisma/orm-extension-supabase@29921

@prisma/orm-family-mongo

npm i https://pkg.pr.new/@prisma/orm-family-mongo@29921

@prisma/orm-family-sql

npm i https://pkg.pr.new/@prisma/orm-family-sql@29921

@prisma/orm-framework

npm i https://pkg.pr.new/@prisma/orm-framework@29921

@prisma/orm-mongo

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

@prisma/orm-postgres

npm i https://pkg.pr.new/@prisma/orm-postgres@29921

@prisma/orm-sqlite

npm i https://pkg.pr.new/@prisma/orm-sqlite@29921

@prisma/orm-target-mongo

npm i https://pkg.pr.new/@prisma/orm-target-mongo@29921

@prisma/orm-target-postgres

npm i https://pkg.pr.new/@prisma/orm-target-postgres@29921

@prisma/orm-target-sqlite

npm i https://pkg.pr.new/@prisma/orm-target-sqlite@29921

@prisma/orm-toolchain

npm i https://pkg.pr.new/@prisma/orm-toolchain@29921

commit: 6922827

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
postgres / no-emit 171.55 KB (+0.35% 🔺)
postgres / emit 148.73 KB (+0.39% 🔺)
mongo / no-emit 101.15 KB (+0.69% 🔺)
mongo / emit 91.01 KB (+0.84% 🔺)
cf-worker / no-emit 195.88 KB (+0.3% 🔺)
cf-worker / emit 170.59 KB (+0.37% 🔺)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (2)
packages/2-mongo-family/1-foundation/mongo-codec/src/codecs.ts (1)

57-57: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Name both operations in the comment.

The runtime now allocates a CodecCallContext for execute() calls as well as query() calls. The SQL counterpart in packages/2-sql/5-runtime/src/codecs/encoding.ts Line 74 says "the surrounding query or execute call". Use the same wording here.

📝 Proposed wording change
-  // The runtime allocates one `CodecCallContext` per `runtime.query()` call (no caller-supplied `signal` produces `{}` instead of `undefined`) and threads it as a non-optional reference to every codec call. The author surface keeps the second parameter optional so single-arg `(value) => …` authors continue to satisfy the signature via TypeScript's bivariance for trailing parameters.
+  // The runtime allocates one `CodecCallContext` per `runtime.query()` or `runtime.execute()` call (no caller-supplied `signal` produces `{}` instead of `undefined`) and threads it as a non-optional reference to every codec call. The author surface keeps the second parameter optional so single-arg `(value) => …` authors continue to satisfy the signature via TypeScript's bivariance for trailing parameters.
🤖 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 `@packages/2-mongo-family/1-foundation/mongo-codec/src/codecs.ts` at line 57,
Update the comment near the codec call context definition to name both runtime
operations, stating that one CodecCallContext is allocated per surrounding query
or execute call. Keep the existing explanation about omitted signals,
non-optional codec references, and the optional author-facing parameter
unchanged.
packages/1-framework/1-core/framework-components/src/execution/run-with-middleware.ts (1)

41-41: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace the bare as cast with blindCast.

Line 41 uses a bare double cast in production code. The coding guidelines forbid bare as casts outside tests and as const. If this cast already existed before the change, keep it and treat the cleanup as separate work.

♻️ Proposed change
-        rowSource = result.rows as unknown as AsyncIterable<Row> | Iterable<Row>;
+        rowSource = blindCast<
+          AsyncIterable<Row> | Iterable<Row>,
+          'Intercepted rows are typed as Record<string, unknown>; the caller owns row typing'
+        >(result.rows);

As per coding guidelines: "Do not use bare as casts in production code. Use blindCast<T, \"Reason\"> or castAs<T> from @internal/utils/casts".

🤖 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
`@packages/1-framework/1-core/framework-components/src/execution/run-with-middleware.ts`
at line 41, Replace the double cast assigned to rowSource in the
run-with-middleware execution flow with blindCast, supplying the target
AsyncIterable<Row> | Iterable<Row> type and a concise reason; preserve the
existing assignment behavior without changing surrounding logic.

Sources: Coding guidelines, Learnings

🤖 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 `@packages/1-framework/1-core/framework-components/src/shared/codec-types.ts`:
- Line 34: Update the CodecCallContext documentation in
packages/1-framework/1-core/framework-components/src/shared/codec-types.ts:34-34
and both encode/decode documentation blocks in
packages/1-framework/1-core/framework-components/src/shared/codec.ts:44-46 to
describe context allocation once per runtime operation, covering query(),
queryPrepared(), and execute(), rather than query() only.

In
`@packages/1-framework/1-core/framework-components/test/runtime-core-options.types.test-d.ts`:
- Around line 61-68: Extend the “RuntimeExecutor operations accept options arg”
type test to assert ExecuteParams[1] with the same readonly signal/scope options
union currently used for QueryParams[1]. Keep the existing query assertion
unchanged and add the corresponding execute assertion so both RuntimeExecutor
methods are covered.

In `@packages/2-sql/4-lanes/relational-core/README.md`:
- Line 133: Update the README documentation around codec context to state that
the runtime allocates one SqlCodecCallContext for both runtime.query(plan, {
signal }) and RuntimeCore.execute() calls. Clarify that the same non-optional
context reference is threaded through every codec dispatch, using an empty {}
when no signal is provided, while retaining the existing guidance that codecs
may ignore the context.

In `@packages/2-sql/4-lanes/relational-core/src/runtime-scope.ts`:
- Around line 23-26: Update RuntimeScope.execute to accept only
SqlExecutionPlan, while leaving RuntimeScope.query capable of accepting
SqlOrmPlan<Row>. Adjust the relevant type import or reference and preserve the
existing SqlStatementStats return type so row-producing SqlQueryPlan values are
rejected at compile time.

In `@packages/3-extensions/sql-orm-client/src/collection.ts`:
- Line 1692: Route count-only DML plans through execute() instead of
queryPlanRows() or scope.query(): at
packages/3-extensions/sql-orm-client/src/collection.ts:1692 use
this.ctx.runtime.execute(plan), at :1701 use this.ctx.runtime.execute(compiled),
and at :2218 use scope.execute(deletePlan). Apply these changes in the
createAndCount and deleteAll flows while preserving their existing count
handling.

In `@packages/3-extensions/sql-orm-client/src/mutation-executor.ts`:
- Line 1046: Route non-returning DML through execution APIs rather than row
queries: in packages/3-extensions/sql-orm-client/src/mutation-executor.ts at
lines 1046, 1092, and 1263, change the compileInsertCount, compileDeleteCount,
and compileUpdateCount paths to use await scope.execute(compiled); in
test/integration/test/scalar-lists/psl-list-roundtrip.integration.test.ts at
lines 231 and 316, change the non-returning insert calls to
runtime.execute(...). Preserve query-based handling for row-returning and SELECT
plans.

In
`@skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md`:
- Around line 27-33: Update the migration table headers to replace “Before 0.18”
and “0.18 translation” with the actual `8.0.0-rc.1` and `8.0.0-rc.2` version
labels, keeping the existing translation rows unchanged.

---

Nitpick comments:
In
`@packages/1-framework/1-core/framework-components/src/execution/run-with-middleware.ts`:
- Line 41: Replace the double cast assigned to rowSource in the
run-with-middleware execution flow with blindCast, supplying the target
AsyncIterable<Row> | Iterable<Row> type and a concise reason; preserve the
existing assignment behavior without changing surrounding logic.

In `@packages/2-mongo-family/1-foundation/mongo-codec/src/codecs.ts`:
- Line 57: Update the comment near the codec call context definition to name
both runtime operations, stating that one CodecCallContext is allocated per
surrounding query or execute call. Keep the existing explanation about omitted
signals, non-optional codec references, and the optional author-facing parameter
unchanged.
🪄 Autofix

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 Plus

Run ID: 097890dc-5ee0-411a-afd1-2595be58a673

📥 Commits

Reviewing files that changed from the base of the PR and between a76a6c5 and fc74d2d.

⛔ Files ignored due to path filters (22)
  • projects/affected-row-counts/plan.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/01-framework-runtime-middleware-round2.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/01-framework-runtime-middleware.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/02-sql-runtime-query-execute-round2.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/02-sql-runtime-query-execute-round3.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/02-sql-runtime-query-execute.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/03-mongo-runtime-statistics-round2.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/03-mongo-runtime-statistics.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/04-supabase-role-scopes.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/05-sql-count-terminals.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/06-close-hard-cut-round2.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/06-close-hard-cut-round3.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/06-close-hard-cut-round4.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/06-close-hard-cut.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/07-record-upgrade-instructions-round2.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/07-record-upgrade-instructions-round3.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/07-record-upgrade-instructions.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/plan.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/spec.md is excluded by !projects/**
  • projects/affected-row-counts/slices/query-execute-split/plan.md is excluded by !projects/**
  • projects/affected-row-counts/slices/query-execute-split/spec.md is excluded by !projects/**
  • projects/affected-row-counts/spec.md is excluded by !projects/**
📒 Files selected for processing (209)
  • apps/telemetry-backend/src/handler.ts
  • examples/bundle-size/src/mongo/main-emit.ts
  • examples/bundle-size/src/mongo/main.ts
  • examples/bundle-size/src/postgres-worker/worker-emit.ts
  • examples/bundle-size/src/postgres-worker/worker.ts
  • examples/bundle-size/src/postgres/main-emit.ts
  • examples/bundle-size/src/postgres/main.ts
  • examples/mongo-blog-leaderboard/README.md
  • examples/mongo-blog-leaderboard/src/queries.ts
  • examples/mongo-demo/scripts/cache-demo.ts
  • examples/mongo-demo/src/server.ts
  • examples/mongo-demo/test/cache-middleware.test.ts
  • examples/mongo-demo/test/query-builder-writes.test.ts
  • examples/paradedb-demo/src/queries/bm25-cast-demo.ts
  • examples/paradedb-demo/src/queries/bm25-chain-demo.ts
  • examples/paradedb-demo/src/queries/bm25-fuzzy.ts
  • examples/paradedb-demo/src/queries/bm25-match.ts
  • examples/paradedb-demo/src/queries/bm25-mode-tour.ts
  • examples/paradedb-demo/src/queries/bm25-proximity-chain.ts
  • examples/paradedb-demo/src/queries/bm25-proximity.ts
  • examples/paradedb-demo/src/queries/bm25-top-by-score.ts
  • examples/prisma-8-cloudflare-worker/README.md
  • examples/prisma-8-cloudflare-worker/scripts/seed.ts
  • examples/prisma-8-cloudflare-worker/src/worker.ts
  • examples/prisma-8-demo-sqlite/scripts/seed.ts
  • examples/prisma-8-demo-sqlite/src/main.ts
  • examples/prisma-8-demo-sqlite/src/queries/dml-operations.ts
  • examples/prisma-8-demo-sqlite/src/queries/get-user-by-email-prepared.ts
  • examples/prisma-8-demo-sqlite/src/queries/get-users.ts
  • examples/prisma-8-demo-sqlite/src/transactions/add-posts-within-quota.ts
  • examples/prisma-8-demo/scripts/seed.ts
  • examples/prisma-8-demo/src/prisma-no-emit/priority-feed.ts
  • examples/prisma-8-demo/src/prisma/slow-query-warning.ts
  • examples/prisma-8-demo/src/queries/cross-author-similarity.ts
  • examples/prisma-8-demo/src/queries/dml-operations.ts
  • examples/prisma-8-demo/src/queries/enum-default-demo-no-emit.ts
  • examples/prisma-8-demo/src/queries/enum-default-demo.ts
  • examples/prisma-8-demo/src/queries/get-all-posts-unbounded.ts
  • examples/prisma-8-demo/src/queries/get-posts-by-priority.ts
  • examples/prisma-8-demo/src/queries/get-user-by-email-prepared.ts
  • examples/prisma-8-demo/src/queries/get-user-by-id-no-emit.ts
  • examples/prisma-8-demo/src/queries/get-user-by-id.ts
  • examples/prisma-8-demo/src/queries/get-user-posts-no-emit.ts
  • examples/prisma-8-demo/src/queries/get-user-posts.ts
  • examples/prisma-8-demo/src/queries/get-users-cached.ts
  • examples/prisma-8-demo/src/queries/get-users-no-emit.ts
  • examples/prisma-8-demo/src/queries/get-users.ts
  • examples/prisma-8-demo/src/queries/raw-sql-demo.ts
  • examples/prisma-8-demo/src/queries/similarity-search.ts
  • examples/prisma-8-demo/test/enum-surface.integration.test.ts
  • examples/prisma-8-demo/test/repositories.integration.test.ts
  • examples/prisma-8-demo/test/slow-query-warning.test.ts
  • examples/prisma-8-postgis-demo/src/queries/find-cafes-near-point.ts
  • examples/prisma-8-postgis-demo/test/queries.e2e.test.ts
  • examples/react-router-demo/app/routes/users.tsx
  • examples/retail-store/src/data/events.ts
  • examples/retail-store/src/data/products.ts
  • examples/supabase/src/profile-queries.ts
  • examples/supabase/src/session-queries.ts
  • packages/1-framework/1-core/framework-components/src/execution/run-with-middleware.ts
  • packages/1-framework/1-core/framework-components/src/execution/runtime-core.ts
  • packages/1-framework/1-core/framework-components/src/execution/runtime-middleware.ts
  • packages/1-framework/1-core/framework-components/src/exports/runtime.ts
  • packages/1-framework/1-core/framework-components/src/shared/codec-types.ts
  • packages/1-framework/1-core/framework-components/src/shared/codec.ts
  • packages/1-framework/1-core/framework-components/test/before-execute-chain.test.ts
  • packages/1-framework/1-core/framework-components/test/mock-family.test.ts
  • packages/1-framework/1-core/framework-components/test/run-execute-with-middleware.test.ts
  • packages/1-framework/1-core/framework-components/test/run-with-middleware.intercept.test.ts
  • packages/1-framework/1-core/framework-components/test/run-with-middleware.test.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core-options.test.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core-options.types.test-d.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core.test.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core.types.test-d.ts
  • packages/1-framework/1-core/framework-components/test/runtime-middleware.types.test-d.ts
  • packages/2-mongo-family/1-foundation/mongo-codec/src/codecs.ts
  • packages/2-mongo-family/5-query-builders/orm/src/collection.ts
  • packages/2-mongo-family/5-query-builders/orm/src/executor.ts
  • packages/2-mongo-family/5-query-builders/orm/test/collection.test.ts
  • packages/2-mongo-family/7-runtime/src/mongo-runtime.ts
  • packages/2-mongo-family/7-runtime/test/aggregate.test.ts
  • packages/2-mongo-family/7-runtime/test/content-hash-guard.test.ts
  • packages/2-mongo-family/7-runtime/test/decode-via-query-builder.test.ts
  • packages/2-mongo-family/7-runtime/test/decode.integration.test.ts
  • packages/2-mongo-family/7-runtime/test/delete-many.test.ts
  • packages/2-mongo-family/7-runtime/test/delete.test.ts
  • packages/2-mongo-family/7-runtime/test/execute-param-mutator-wiring.test.ts
  • packages/2-mongo-family/7-runtime/test/find-one-and-delete.test.ts
  • packages/2-mongo-family/7-runtime/test/find-one-and-update.test.ts
  • packages/2-mongo-family/7-runtime/test/insert-many.test.ts
  • packages/2-mongo-family/7-runtime/test/insert.test.ts
  • packages/2-mongo-family/7-runtime/test/mongo-middleware.test.ts
  • packages/2-mongo-family/7-runtime/test/mongo-runtime-abort.test.ts
  • packages/2-mongo-family/7-runtime/test/mongo-runtime.types.test-d.ts
  • packages/2-mongo-family/7-runtime/test/raw-commands.test.ts
  • packages/2-mongo-family/7-runtime/test/read-plan.test.ts
  • packages/2-mongo-family/7-runtime/test/runtime-types.test-d.ts
  • packages/2-mongo-family/7-runtime/test/update-many.test.ts
  • packages/2-mongo-family/7-runtime/test/update.test.ts
  • packages/2-sql/4-lanes/relational-core/README.md
  • packages/2-sql/4-lanes/relational-core/src/ast/types.ts
  • packages/2-sql/4-lanes/relational-core/src/runtime-scope.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.types.test-d.ts
  • packages/2-sql/4-lanes/relational-core/test/runtime-scope.types.test-d.ts
  • packages/2-sql/5-runtime/src/codecs/encoding.ts
  • packages/2-sql/5-runtime/src/prepared/prepared-statement.ts
  • packages/2-sql/5-runtime/src/prepared/types.ts
  • packages/2-sql/5-runtime/src/sql-runtime.ts
  • packages/2-sql/5-runtime/test/async-iterable-result.test.ts
  • packages/2-sql/5-runtime/test/before-compile-chain.test.ts
  • packages/2-sql/5-runtime/test/budgets.test.ts
  • packages/2-sql/5-runtime/test/intercept-decoding.test.ts
  • packages/2-sql/5-runtime/test/lints.test.ts
  • packages/2-sql/5-runtime/test/marker-verification.test.ts
  • packages/2-sql/5-runtime/test/marker-vs-intercept-ordering.test.ts
  • packages/2-sql/5-runtime/test/plan-execution-id.test.ts
  • packages/2-sql/5-runtime/test/prepared.test.ts
  • packages/2-sql/5-runtime/test/prepared.types.test-d.ts
  • packages/2-sql/5-runtime/test/raw-connection-seam.test.ts
  • packages/2-sql/5-runtime/test/runtime-ctx-passthrough.test.ts
  • packages/2-sql/5-runtime/test/scope-plumbing.test.ts
  • packages/2-sql/5-runtime/test/sql-runtime-abort.test.ts
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts
  • packages/2-sql/5-runtime/test/utils.ts
  • packages/3-extensions/middleware-cache/src/cache-middleware.ts
  • packages/3-extensions/middleware-cache/test/cache-key.test.ts
  • packages/3-extensions/middleware-cache/test/cache-middleware.test.ts
  • packages/3-extensions/mongo/src/runtime/mongo.ts
  • packages/3-extensions/mongo/test/mongo.test.ts
  • packages/3-extensions/mongo/test/mongo.types.test-d.ts
  • packages/3-extensions/postgres/README.md
  • packages/3-extensions/postgres/src/runtime/postgres-serverless.ts
  • packages/3-extensions/postgres/src/runtime/postgres.ts
  • packages/3-extensions/sql-orm-client/src/collection-dispatch.ts
  • packages/3-extensions/sql-orm-client/src/collection-mutation-dispatch.ts
  • packages/3-extensions/sql-orm-client/src/collection.ts
  • packages/3-extensions/sql-orm-client/src/grouped-collection.ts
  • packages/3-extensions/sql-orm-client/src/mutation-executor.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-rows.ts
  • packages/3-extensions/sql-orm-client/test/annotations.test.ts
  • packages/3-extensions/sql-orm-client/test/collection-dispatch.test.ts
  • packages/3-extensions/sql-orm-client/test/collection-runtime.test.ts
  • packages/3-extensions/sql-orm-client/test/collection-variant.test.ts
  • packages/3-extensions/sql-orm-client/test/helpers.ts
  • packages/3-extensions/sql-orm-client/test/mutation-executor.test.ts
  • packages/3-extensions/sql-orm-client/test/orm-namespace-crud.test.ts
  • packages/3-extensions/sql-orm-client/test/raw-compiled-query.test.ts
  • packages/3-extensions/sql-orm-client/test/runtime-queryable.types.test-d.ts
  • packages/3-extensions/sqlite/src/runtime/sqlite.ts
  • packages/3-extensions/supabase/README.md
  • packages/3-extensions/supabase/src/runtime/supabase-runtime.ts
  • packages/3-extensions/supabase/src/runtime/supabase.ts
  • packages/3-extensions/supabase/test/explicit-namespace-query.integration.test.ts
  • packages/3-extensions/supabase/test/fixtures/example-app/session-queries.ts
  • packages/3-extensions/supabase/test/role-bound-db.types.test-d.ts
  • packages/3-extensions/supabase/test/service-role-refresh-tokens.integration.test.ts
  • packages/3-extensions/supabase/test/skeleton.integration.test.ts
  • packages/3-extensions/supabase/test/supabase-facade.test.ts
  • packages/3-extensions/supabase/test/supabase-runtime.test.ts
  • packages/3-mongo-target/2-mongo-adapter/src/resolve-value.ts
  • packages/3-targets/6-adapters/postgres/test/mixed-case-enum-cast.integration.test.ts
  • packages/3-targets/6-adapters/postgres/test/scalar-list-codec-roundtrip.integration.test.ts
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • test/e2e/framework/test/dml.test.ts
  • test/e2e/framework/test/multi-namespace-runtime.test.ts
  • test/e2e/framework/test/runtime.basic.test.ts
  • test/e2e/framework/test/runtime.joins.test.ts
  • test/e2e/framework/test/runtime.prepared.test.ts
  • test/e2e/framework/test/sqlite/prepared.test.ts
  • test/e2e/framework/test/sqlite/raw-sql.test.ts
  • test/e2e/framework/test/sqlite/runtime.verify-marker.missing-table.test.ts
  • test/e2e/framework/test/sqlite/sql-builder.test.ts
  • test/e2e/framework/test/sqlite/transaction.test.ts
  • test/e2e/framework/test/sqlite/utils.ts
  • test/e2e/framework/test/transaction.test.ts
  • test/integration/test/cross-package/cross-family-middleware.test.ts
  • test/integration/test/cross-package/middleware-cache.test.ts
  • test/integration/test/mongo-runtime/query-builder.test.ts
  • test/integration/test/mongo/execution-abort.test.ts
  • test/integration/test/mongo/expr-filter.test.ts
  • test/integration/test/mongo/query-builder.test.ts
  • test/integration/test/namespaced-accessors-e2e.integration.test.ts
  • test/integration/test/ports/prisma/functional/enums/enums.test.ts
  • test/integration/test/ports/prisma/functional/legacy-aggregate-raw/legacy-aggregate-raw.test.ts
  • test/integration/test/rewriting-middleware.integration.test.ts
  • test/integration/test/runtime.verify-marker.missing-table.integration.test.ts
  • test/integration/test/scalar-lists/psl-list-roundtrip.integration.test.ts
  • test/integration/test/sql-builder/distinct.test.ts
  • test/integration/test/sql-builder/execution-abort.test.ts
  • test/integration/test/sql-builder/execution.test.ts
  • test/integration/test/sql-builder/extension-functions.test.ts
  • test/integration/test/sql-builder/group-by.test.ts
  • test/integration/test/sql-builder/join.test.ts
  • test/integration/test/sql-builder/mutation-defaults.test.ts
  • test/integration/test/sql-builder/mutation.test.ts
  • test/integration/test/sql-builder/order-by.test.ts
  • test/integration/test/sql-builder/pagination.test.ts
  • test/integration/test/sql-builder/raw-sql.integration.test.ts
  • test/integration/test/sql-builder/select.test.ts
  • test/integration/test/sql-builder/subquery.test.ts
  • test/integration/test/sql-builder/where.test.ts
  • test/integration/test/sql-orm-client/collection-mutation-defaults.test.ts
  • test/integration/test/sql-orm-client/count-terminal-interleaving.test.ts
  • test/integration/test/sql-orm-client/delete.test.ts
  • test/integration/test/sql-orm-client/helpers.ts
  • test/integration/test/sql-orm-client/integration-helpers.ts
  • test/integration/test/sql-orm-client/runtime-helpers.ts
  • test/integration/test/sql-orm-client/update.test.ts
💤 Files with no reviewable changes (1)
  • packages/2-sql/5-runtime/src/prepared/prepared-statement.ts

Comment thread packages/1-framework/1-core/framework-components/src/shared/codec-types.ts Outdated
Comment thread packages/2-sql/4-lanes/relational-core/README.md Outdated
Comment thread packages/2-sql/4-lanes/relational-core/src/runtime-scope.ts
Comment thread packages/3-extensions/sql-orm-client/src/collection.ts Outdated
Comment thread packages/3-extensions/sql-orm-client/src/mutation-executor.ts Outdated
Comment thread skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md Outdated
@SevInf
SevInf force-pushed the tml-3168-count-terminals branch from fc74d2d to 8e038b7 Compare August 7, 2026 13:00

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@packages/3-targets/7-drivers/postgres/test/driver.prepared.test.ts`:
- Around line 137-155: Update the early-termination test around makeMockClient
and the driver.query loop to track the source or cursor close operation, then
assert that it was invoked after the consumer breaks. Preserve the existing
first-row assertion while explicitly verifying cleanup rather than only
successful iteration.

In
`@skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md`:
- Around line 21-23: Remove or revise the PR `#29910` HTML comment in the
runtime-query-execute-hard-cut instructions so it no longer claims changes are
empty or that downstream translation is unnecessary; if the note belongs to a
different upgrade, move it there instead. Keep the note consistent with the
migration instructions defined in this file.
🪄 Autofix

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 Plus

Run ID: 1b426d35-bf15-492f-9440-bcdbded42ba1

📥 Commits

Reviewing files that changed from the base of the PR and between fc74d2d and 8e038b7.

📒 Files selected for processing (11)
  • examples/prisma-8-cloudflare-worker/src/prisma/db.ts
  • packages/2-mongo-family/7-runtime/src/mongo-runtime.ts
  • packages/2-mongo-family/7-runtime/test/mongo-middleware.test.ts
  • packages/3-targets/7-drivers/postgres/src/postgres-driver.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.stream-portal-protection.integration.test.ts
  • packages/3-targets/7-drivers/postgres/test/normalize-error.test.ts
  • scripts/lint-framework-vocabulary.config.json
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • test/integration/test/sql-orm-client/runtime-helpers.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • test/integration/test/sql-orm-client/runtime-helpers.ts
  • packages/2-mongo-family/7-runtime/src/mongo-runtime.ts
  • packages/2-mongo-family/7-runtime/test/mongo-middleware.test.ts
  • skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md

Comment thread packages/3-targets/7-drivers/postgres/test/driver.prepared.test.ts
@SevInf
SevInf force-pushed the tml-3168-count-terminals branch from 8e038b7 to be82b3b Compare August 7, 2026 13:58

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 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 `@docs/reference/error-reference.md`:
- Around line 594-597: Update the conflicting execute() descriptions throughout
the error reference so they consistently document execute() as the statistics
operation and the query operation as returning streamed rows. Preserve the
existing error-specific details while correcting only the operation/return-value
terminology.
🪄 Autofix

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 Plus

Run ID: a63f1e7e-e760-429d-b639-bd56841e0de1

📥 Commits

Reviewing files that changed from the base of the PR and between 8e038b7 and be82b3b.

📒 Files selected for processing (4)
  • docs/reference/error-reference.md
  • packages/3-extensions/supabase/test/supabase-runtime.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.stream-portal-protection.integration.test.ts
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/3-targets/7-drivers/postgres/test/driver.stream-portal-protection.integration.test.ts
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • packages/3-extensions/supabase/test/supabase-runtime.test.ts

Comment thread docs/reference/error-reference.md
Comment thread examples/prisma-8-demo-sqlite/src/queries/get-user-by-email-prepared.ts Outdated
Comment thread examples/prisma-8-demo/src/queries/get-user-by-email-prepared.ts Outdated
Comment thread examples/retail-store/src/data/events.ts
Comment thread examples/retail-store/src/data/products.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/2-sql/5-runtime/src/sql-runtime.ts (1)

211-218: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the operation-hook documentation.

Lines 213 and 217-218 state that the production pipeline runs beforeExecute. prepareQueryExecution() runs runBeforeQueryChain, and prepareExecuteExecution() runs runBeforeExecuteChain. State that the hook depends on the selected operation.

🤖 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 `@packages/2-sql/5-runtime/src/sql-runtime.ts` around lines 211 - 218, Update
the operation-hook documentation near lowerToDraft and encodeDraftParams to
state that the middleware hook depends on the selected operation:
prepareQueryExecution() runs runBeforeQueryChain, while
prepareExecuteExecution() runs runBeforeExecuteChain. Remove the claim that the
production pipeline uniformly runs beforeExecute, while preserving the
explanation of the split lower/encode flow.
🤖 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 `@packages/1-framework/1-core/framework-components/README.md`:
- Line 15: Update packages/1-framework/1-core/framework-components/README.md at
line 15 to state that each query() and execute() call creates a
CodecCallContext. Update packages/2-mongo-family/7-runtime/README.md at line 53
by replacing executor and unified-flow descriptions with separate row-query and
statement-statistics operations, reflecting Mongo’s query() and execute() APIs.

In `@packages/2-sql/5-runtime/src/sql-runtime.ts`:
- Around line 183-184: Replace the bare cast in the contentHash callback with
the runtime-specific blindCast helper, using SqlExecutionPlan and the required
explanation string. Import blindCast from `@internal/utils/casts` and preserve the
existing computeSqlContentHash call.

In `@test/e2e/framework/test/sqlite/raw-sql.test.ts`:
- Line 145: Remove the duplicate capturedEntries const declaration in each
affected block, retaining exactly one declaration per block in
test/e2e/framework/test/sqlite/raw-sql.test.ts at lines 145-145 and 183-183, and
test/integration/test/sql-builder/raw-sql.integration.test.ts at lines 198-198
and 241-241.

---

Outside diff comments:
In `@packages/2-sql/5-runtime/src/sql-runtime.ts`:
- Around line 211-218: Update the operation-hook documentation near lowerToDraft
and encodeDraftParams to state that the middleware hook depends on the selected
operation: prepareQueryExecution() runs runBeforeQueryChain, while
prepareExecuteExecution() runs runBeforeExecuteChain. Remove the claim that the
production pipeline uniformly runs beforeExecute, while preserving the
explanation of the split lower/encode flow.
🪄 Autofix

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 Plus

Run ID: ce3abf82-8b39-4e65-ac7a-3a096973f0a8

📥 Commits

Reviewing files that changed from the base of the PR and between a630ecf and eb4669c.

⛔ Files ignored due to path filters (7)
  • projects/affected-row-counts/design-decisions.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/08-revert-unapproved-middleware-design.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/09-operation-specific-middleware-hooks-round2.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/dispatches/09-operation-specific-middleware-hooks.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/plan.md is excluded by !projects/**
  • projects/affected-row-counts/slices/count-terminals/spec.md is excluded by !projects/**
  • projects/affected-row-counts/spec.md is excluded by !projects/**
📒 Files selected for processing (64)
  • docs/reference/error-reference.md
  • examples/prisma-8-demo/src/orm-client/find-user-by-id-cached.ts
  • examples/prisma-8-demo/src/prisma/db.ts
  • examples/prisma-8-demo/src/prisma/slow-query-warning.ts
  • examples/prisma-8-demo/test/repositories.integration.test.ts
  • examples/prisma-8-demo/test/slow-query-warning.test.ts
  • examples/supabase/test/real-supabase.acceptance.test.ts
  • packages/1-framework/1-core/framework-components/README.md
  • packages/1-framework/1-core/framework-components/src/execution/before-execute-chain.ts
  • packages/1-framework/1-core/framework-components/src/execution/run-with-middleware.ts
  • packages/1-framework/1-core/framework-components/src/execution/runtime-core.ts
  • packages/1-framework/1-core/framework-components/src/execution/runtime-error.ts
  • packages/1-framework/1-core/framework-components/src/execution/runtime-middleware.ts
  • packages/1-framework/1-core/framework-components/src/exports/runtime.ts
  • packages/1-framework/1-core/framework-components/test/before-execute-chain.test.ts
  • packages/1-framework/1-core/framework-components/test/mock-family.test.ts
  • packages/1-framework/1-core/framework-components/test/operation-specific-middleware.test.ts
  • packages/1-framework/1-core/framework-components/test/operation-specific-middleware.types.test-d.ts
  • packages/1-framework/1-core/framework-components/test/run-with-middleware.intercept.test.ts
  • packages/1-framework/1-core/framework-components/test/run-with-middleware.test.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core-options.test.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core-options.types.test-d.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core.test.ts
  • packages/1-framework/1-core/framework-components/test/runtime-core.types.test-d.ts
  • packages/1-framework/1-core/framework-components/test/runtime-middleware.types.test-d.ts
  • packages/2-mongo-family/7-runtime/README.md
  • packages/2-mongo-family/7-runtime/src/content-hash.ts
  • packages/2-mongo-family/7-runtime/src/mongo-middleware.ts
  • packages/2-mongo-family/7-runtime/src/mongo-runtime.ts
  • packages/2-mongo-family/7-runtime/test/content-hash-guard.test.ts
  • packages/2-mongo-family/7-runtime/test/execute-param-mutator-wiring.test.ts
  • packages/2-mongo-family/7-runtime/test/mongo-middleware.test.ts
  • packages/2-sql/5-runtime/README.md
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/5-runtime/src/middleware/budgets.ts
  • packages/2-sql/5-runtime/src/middleware/lints.ts
  • packages/2-sql/5-runtime/src/middleware/sql-middleware.ts
  • packages/2-sql/5-runtime/src/sql-runtime.ts
  • packages/2-sql/5-runtime/test/before-compile-chain.test.ts
  • packages/2-sql/5-runtime/test/budgets.test.ts
  • packages/2-sql/5-runtime/test/intercept-decoding.test.ts
  • packages/2-sql/5-runtime/test/marker-verification.test.ts
  • packages/2-sql/5-runtime/test/marker-vs-intercept-ordering.test.ts
  • packages/2-sql/5-runtime/test/plan-execution-id.test.ts
  • packages/2-sql/5-runtime/test/prepared.test.ts
  • packages/2-sql/5-runtime/test/raw-connection-seam.test.ts
  • packages/2-sql/5-runtime/test/runtime-ctx-passthrough.test.ts
  • packages/2-sql/5-runtime/test/scope-plumbing.test.ts
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts
  • packages/3-extensions/middleware-cache/README.md
  • packages/3-extensions/middleware-cache/src/cache-middleware.ts
  • packages/3-extensions/middleware-cache/test/cache-key.test.ts
  • packages/3-extensions/middleware-cache/test/cache-middleware.test.ts
  • packages/3-extensions/middleware-cache/test/cache-query-only.test.ts
  • packages/3-extensions/postgres/test/postgres-serverless.test.ts
  • packages/3-extensions/supabase/test/explicit-namespace-query.integration.test.ts
  • packages/3-extensions/supabase/test/rls-role-binding.integration.test.ts
  • packages/3-extensions/supabase/test/supabase-runtime.test.ts
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • test/e2e/framework/test/sqlite/raw-sql.test.ts
  • test/integration/test/cross-package/cross-family-middleware.test.ts
  • test/integration/test/cross-package/middleware-cache.test.ts
  • test/integration/test/sql-builder/raw-sql.integration.test.ts
💤 Files with no reviewable changes (1)
  • packages/1-framework/1-core/framework-components/test/runtime-core.types.test-d.ts
🚧 Files skipped from review as they are similar to previous changes (17)
  • packages/2-sql/5-runtime/test/before-compile-chain.test.ts
  • packages/2-sql/5-runtime/test/runtime-ctx-passthrough.test.ts
  • packages/2-mongo-family/7-runtime/test/execute-param-mutator-wiring.test.ts
  • skills/prisma-next-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • packages/2-sql/5-runtime/test/raw-connection-seam.test.ts
  • skills/prisma-8-extension-upgrade/upgrades/8.0.0-rc.1-to-8.0.0-rc.2/instructions.md
  • packages/2-sql/5-runtime/test/scope-plumbing.test.ts
  • packages/2-sql/5-runtime/test/marker-vs-intercept-ordering.test.ts
  • test/integration/test/cross-package/cross-family-middleware.test.ts
  • packages/2-sql/5-runtime/test/intercept-decoding.test.ts
  • docs/reference/error-reference.md
  • test/integration/test/cross-package/middleware-cache.test.ts
  • packages/2-mongo-family/7-runtime/test/mongo-middleware.test.ts
  • packages/3-extensions/supabase/test/supabase-runtime.test.ts
  • packages/2-sql/5-runtime/test/prepared.test.ts
  • packages/1-framework/1-core/framework-components/src/execution/runtime-middleware.ts
  • packages/2-mongo-family/7-runtime/src/mongo-runtime.ts

Comment thread packages/1-framework/1-core/framework-components/README.md
Comment thread packages/2-sql/5-runtime/src/sql-runtime.ts Outdated
Comment thread test/e2e/framework/test/sqlite/raw-sql.test.ts
@SevInf
SevInf force-pushed the tml-3168-count-terminals branch from eb4669c to c0ac59a Compare August 11, 2026 08:37
@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it for the distinct findings in this review body: I will update the Mongo codec context comment, replace the run-with-middleware bare cast, and add execute() options coverage to the framework type test. The other listed items are already tracked by their corresponding unresolved inline threads and are recorded as duplicate sub-actions.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it for the distinct findings in this review body: the prepared-query cleanup is tracked by the existing inline thread, and I will correct the stale PR #29910 upgrade note in the extension upgrade guidance.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it. I will correct the conflicting execute()/query() terminology in the runtime error reference while preserving the existing error-specific details.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it for the distinct findings in this review body: the README, SQL cast, and capturedEntries items are tracked by existing inline actions, and I will correct the operation-specific hook documentation in sql-runtime.ts.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it 👍 I will update the Mongo codec context comment to name both query() and execute().

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

Done 👍 Updated the Mongo codec context comment to name both query() and execute(), preserving the signal and author-compatibility details in b82384d.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it 👍 I will replace the intercepted-row bare double cast with blindCast and preserve behavior.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

Done 👍 Replaced the intercepted-row bare double cast with blindCast in 5fa531f; runtime behavior is unchanged.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it 👍 I will verify and record the execute-options type coverage without duplicating the assertion already present at HEAD.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

Done 👍 ExecuteParams[1] already asserts the same readonly signal/scope options union as query at HEAD (from 75d33b4); verified with the framework-components typecheck and made no duplicate change.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it 👍 I will remove or revise the stale PR #29910 changes: [] note so the extension upgrade guidance matches its hard-cut migration instructions.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

Done 👍 Removed the stale PR #29910 changes: [] note from the extension upgrade guidance in 1203995; the remaining guidance now agrees with the hard-cut migration instructions.

@StevenMcClankerton

Copy link
Copy Markdown
Contributor Author

On it 👍 I will correct the runtime error reference so query() owns row streaming and execute() is described only as the eager statistics operation.

SevInf added 16 commits August 12, 2026 13:14
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
@SevInf
SevInf force-pushed the tml-3168-count-terminals branch from 3ce0835 to a2a67ed Compare August 12, 2026 13:30
SevInf added 4 commits August 12, 2026 14:26
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
@SevInf
SevInf enabled auto-merge August 12, 2026 16:02
@SevInf
SevInf added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit c332c67 Aug 12, 2026
18 checks passed
@SevInf
SevInf deleted the tml-3168-count-terminals branch August 12, 2026 16:06
Thegreatsura pushed a commit to Thegreatsura/prisma that referenced this pull request Aug 14, 2026
## Linked issue

Refs [TML-3166](https://linear.app/prisma-company/issue/TML-3166)

Delivered by [prisma#29907](prisma#29907),
[prisma#29920](prisma#29920), and
[prisma#29921](prisma#29921).

## At a glance

```ts
interface SqlQueryable {
  query<Row>(request: SqlExecuteRequest): AsyncIterable<Row>
  execute(request: SqlExecuteRequest): Promise<{ affectedRows: number }>
}
```

The project is complete: count-returning writes use one statement and
return the database-reported statistic rather than counting rows from a
preceding read.

## Decision

Close the affected-row-counts project by preserving its durable
architecture and semantics in the canonical ADRs, subsystem
documentation, and scorecards, then deleting the transient project
workspace.

## Project DoD verification

- The SQL driver SPI has separate row-query and statement-statistics
operations, with prepared-ness carried by the request handle.
- Postgres and SQLite return real `affectedRows` values, and Mongo maps
`modifiedCount` or `deletedCount` according to the command kind.
- `updateAndCount` and `deleteAndCount` issue one write statement;
integration coverage proves the returned count comes from that write.
- The pre-`SELECT` fallback and retired operation names are absent.
- ADR 210 documents the two-method prepared-statement SPI and
`DRIVER.PREPARE_FAILED` under ADR 239.
- ADR 215 and the runtime subsystem documentation describe the
operation-specific query and execute middleware lifecycles.
- SQL and Mongo scorecards record the shipped count-terminal behavior
and target-specific semantics.
- Manual documentation QA passed for both application users and
extension/driver/middleware authors.
- The mandatory final retro landed a dispatch-DoR guard requiring
explicit design-owner approval for public or cross-family API shapes.
- All tracked project artifacts are deleted and no tracked references to
the removed workspace remain.

## How it fits together

1. ADR 210 records the two-method SQL driver contract and the
runtime-owned prepared-handle lifecycle.
2. ADR 215 and the runtime subsystem page describe `beforeQuery` /
`interceptQuery` / `afterQuery` separately from `beforeExecute` /
`interceptExecute` / `afterExecute`.
3. The Mongo subsystem and both scorecards state each target's native
affected-row semantics and point to qualifying evidence.
4. The reusable process lesson lands in Drive's dispatch Definition of
Ready.
5. The transient specs, plans, dispatch briefs, decision log, QA
artifacts, and retro log are removed.

## Notes for the reviewer

The large runtime-documentation diff replaces stale generic middleware
terminology with the operation-specific lifecycle on `main`. ADR 215
preserves the original May 2026 decision and its rationale under a
historical section while adding the August 2026 amendment.

The manual-QA script, report, and retro were created and committed as
close-out evidence before being removed with the rest of the transient
workspace; their evidence remains in this branch's signed commit
history.

## Testing performed

- Manual QA: durable-documentation read-through for application and
extension-author audiences — pass, no findings
- Local Markdown link validation — no missing links
- `pnpm lint:docs` — pass, with pre-existing package README warnings
- `git diff --check origin/main...HEAD` — pass
- Source and integration behavior — green on merged PR prisma#29921 CI,
including Test, Integration Tests, E2E, Coverage, Type Check, Lint, and
Supabase Acceptance

## Skill update

The existing Prisma Next upgrade instructions shipped with prisma#29921. This
close-out adds no new user-facing API change.

## Checklist

- [x] All commits are signed off (`git commit -s`) per the DCO.
- [x] I read `CONTRIBUTING.md` and the change is scoped to one logical
concern.
- [x] Tests are n/a for this documentation and project-cleanup PR;
merged implementation CI and close-out manual QA provide the behavior
evidence.
- [x] The PR title is in `TML-NNNN: <sentence-case title>` form.
- [x] The Skill update section is filled in.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Query and execute operations now have distinct lifecycles and results:
queries stream rows, while executions report affected-row statistics.
* SQL and MongoDB provide clearer update and delete counts, including
no-op updates and deleted-document totals.
* Prepared statement and transaction behavior is documented with clearer
lazy execution and resource handling details.

* **Documentation**
* Updated architecture, middleware, MongoDB, SQL ORM, and scorecard
documentation to reflect current behavior and supported operations.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Steven McClankerton <tatarintsev@prisma.io>
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.

2 participants