Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

feat(sql): add prepared statements primitive - #444

Merged
SevInf merged 1 commit into
mainfrom
prepared-statements-impl
May 19, 2026
Merged

SevInf merged 1 commit into
mainfrom
prepared-statements-impl

Conversation

@SevInf

@SevInf SevInf commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

closes TML-2381 and TML-2382

Intent

Add a first-class prepared-statement primitive to the SQL DSL that opts users into both kinds of execution reuse: lowering reuse (the AST → SQL pass runs once per prepare) and server-side parse reuse (Postgres parsedStatements keeps one named plan per Client). The same PreparedStatement is reusable across runtime, connection, and transaction scopes — produced once, redirected at execute time.

Change map

The story

  1. The runtime gains prepare(declaration, callback). The callback receives bind-site params proxies and returns a plan via .build(). The runtime invokes the beforeCompile middleware chain on the AST exactly once, lowers via the adapter, and freezes {sql, ast, meta, slots} onto a PreparedStatement. No driver I/O.

  2. Driver SPI gets executePrepared({ sql, params, handle }). The driver never sees the PreparedStatement object — only the lowered SQL, encoded params, and an opaque getter/setter slot. The runtime persists the slot's value in a per-runtime WeakMap, so the handle is GC'd alongside the user's PreparedStatement reference.

  3. Postgres reuses pg's per-Client parsedStatements cache. A driver-scoped allocator mints pn_<n> names. First execute writes Parse with the name; subsequent executes on the same Client skip Parse. A different Client (a fresh pool acquisition) auto-Parses on first use.

  4. Streaming uses a pg-cursor subclass. NamedCursor extends Cursor and overrides only submit — Parse with name, Bind referencing the named statement, then the inherited portal/PortalSuspended/Sync lifecycle handles batched streaming unchanged. The execute path through the driver shares one runQuery(name?) helper with the ad-hoc execute() path.

  5. Stale-handle errors retry once with a fresh name. SQLSTATE 26000 (deallocated name, e.g. after DEALLOCATE ALL) and 0A000 ("cached plan must not change result type" after DDL) are both healed by minting a new pn_<n> and retrying. The same retry layer wraps both the streaming and buffered paths so the behaviour is identical regardless of cursor.disabled.

  6. PreparedStatement.execute(target, params) always names its scope. The target is a RuntimeQueryable (Runtime, RuntimeConnection, RuntimeTransaction, or TransactionContext). Each scope implements executePrepared and routes through the SqlQueryable it is backed by. The same prepared statement is reusable across scopes — prepare once, run against the runtime for one request and against an active transaction for another. There is no implicit binding back to the runtime that produced it.

Behavior changes & evidence

  • Adds runtime.prepare(declaration, callback) returning a PreparedStatement<Params, Row>. Lowers exactly once; no driver I/O. Throws RUNTIME.PREPARE_UNUSED_PARAM when a declared param is unreferenced by the callback's plan.

  • Adds SqlQueryable.executePrepared({ sql, params, handle }) to the driver SPI. The runtime never hands the PreparedStatement to the driver. The handle slot is opaque to the runtime, populated lazily on first execute.

  • Adds Postgres-backed streaming for named prepared statements. NamedCursor extends pg-cursor and overrides only submit so Parse carries a name (and is skipped on subsequent submits when connection.parsedStatements already records it). Bind references the named statement; PortalSuspended/Close/Sync are inherited.

  • Adds stale-handle retry on SQLSTATE 26000 and 0A000. A fresh pn_<n> is minted and the execute is retried exactly once. Any other SQLSTATE is re-surfaced unchanged. If a row was already yielded (mid-stream error), the retry is suppressed to avoid duplicate rows.

  • Adds preparedStatements: false driver opt-out. Skips server-side prepare entirely; routes through the same cursor/buffered path as ad-hoc execute. Lowering reuse on the PreparedStatement is the only win retained, intended for transaction-mode poolers.

  • PreparedStatement.execute(target, params) requires an explicit target. Each RuntimeQueryable scope (Runtime, RuntimeConnection, RuntimeTransaction, TransactionContext) implements executePrepared and routes through its own SqlQueryable. The prepared statement is pure data — no runtime captured at construction.

    • Why: a single PS reused across many transactions over time is the common workload; an implicit "the runtime that made me" binding silently couples scope and forces an awkward second API for the transaction case.
    • Implementation: sql-runtime.ts (RuntimeQueryable, wrapTransaction, withTransaction's txContext), prepared-statement.ts
    • Tests: runtime.prepared.test.ts — a single PS executed inside withTransaction(...) sees the tx's uncommitted writes; the same PS run against the runtime after commit sees the committed row.

Compatibility / migration / risk

  • API shape. ps.execute(target, params) is new — the previous M2 surface ps.execute(params) was never released, so there is no migration burden for external callers. Two example queries under examples/ and existing E2E tests were updated.
  • @types/pg-cursor internals dependency. NamedCursor reads/writes pg-cursor's runtime-only fields (_portal, _conf, _result, _ifNoData, _rowDescription). These have been stable since 2014 and are consumed by pg-cursor's own handlers, so the implicit contract is not new — but a future pg-cursor major could break it. The pg version is pinned via the workspace catalog.
  • connection.parsedStatements. Not declared on @types/pg's Connection (set by Client, not Connection). The cast is local and one field deep.
  • Stale-handle scope. Retry covers 26000 and 0A000 only. A pg error of any other class is re-surfaced unchanged, including a recurrence of 26000/0A000 on the retry attempt.

Follow-ups / open questions

  • Prepared INSERT/UPDATE with parameterised values. The SQL builder's insert({...}) and update({...}) accept TInput, not Expression. A prepared INSERT that takes params.email from the prepare callback doesn't typecheck today. Out of scope for this PR; tracked separately.
  • SQLite driver streaming named statements. The SQLite SPI scaffold is in place (M2) but server-side reuse via per-connection Map<number, StatementSync> is not landed in this PR.

Non-goals / intentionally out of scope

  • Global shape cache / cross-process state. Lifetime is the user's PreparedStatement reference plus the connection.
  • Explicit dispose() / DEALLOCATE. Server-side state is bounded by (distinct PreparedStatements) × (connections that have executed each one) and self-heals on connection recycle.
  • List/array parameter types. The framework has no list codecs yet.
  • Pre-warming PREPARE at pool init. First execute per connection pays the Parse cost.
  • Observability / tracing for prepared executions.

Summary by CodeRabbit

  • New Features

    • Typed prepared-statement API with explicit execute(target, params), runtime/client prepare(), and driver support (Postgres, SQLite); prepared params can drive pagination.
  • Bug Fixes

    • Validation and clear runtime errors for unused or missing declared prepared parameters; safer param encoding/handling.
  • Documentation

    • ADR updated to document prepared-statement author surface and examples.
  • Examples

    • Demo apps add user-by-email-prepared CLI commands.
  • Tests

    • Broad unit/integration/type tests and test fixtures for prepared-statement behavior.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@SevInf has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 16 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 5b60bf25-022d-4bad-adf2-52f415538a69

📥 Commits

Reviewing files that changed from the base of the PR and between 8f770b9 and 634c6cd.

📒 Files selected for processing (48)
  • docs/architecture docs/adrs/ADR 210 - Prepared Statements - Author Surface and Driver SPI.md
  • examples/prisma-next-demo-sqlite/src/main.ts
  • examples/prisma-next-demo-sqlite/src/queries/get-user-by-email-prepared.ts
  • examples/prisma-next-demo/src/main.ts
  • examples/prisma-next-demo/src/queries/get-user-by-email-prepared.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/types.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/util.ts
  • packages/2-sql/4-lanes/relational-core/src/expression.ts
  • packages/2-sql/4-lanes/relational-core/src/middleware/param-ref-mutator.ts
  • packages/2-sql/4-lanes/relational-core/src/sql-execution-plan.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/2-sql/4-lanes/relational-core/test/middleware/param-ref-mutator.test.ts
  • packages/2-sql/4-lanes/relational-core/test/sql-execution-plan.types.test-d.ts
  • packages/2-sql/4-lanes/relational-core/test/utils.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/builder-base.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/query-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/scope.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/grouped-query.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/select-query.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/shared.ts
  • packages/2-sql/5-runtime/src/codecs/decoding.ts
  • packages/2-sql/5-runtime/src/codecs/encoding.ts
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/5-runtime/src/lower-sql-plan.ts
  • packages/2-sql/5-runtime/src/middleware/budgets.ts
  • packages/2-sql/5-runtime/src/prepared/bind-site-params.ts
  • packages/2-sql/5-runtime/src/prepared/encode-prepared.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/codec-async.test.ts
  • packages/2-sql/5-runtime/test/codec-decode-ctx.test.ts
  • packages/2-sql/5-runtime/test/content-hash.test.ts
  • packages/2-sql/5-runtime/test/decode-error-passthrough.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/prepared.test.ts
  • packages/2-sql/5-runtime/test/prepared.types.test-d.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-family-adapter.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
📝 Walkthrough

Walkthrough

Implements typed prepared statements end-to-end: AST prepared-param refs and LoweredParam shape, author-facing prepare/PreparedStatement.execute(target, params) surface, runtime prepare/executePrepared execution and streaming/decoding refactor, adapter/renderer updates for prepared refs, Postgres named-cursor + driver prepared handling, SQLite executePrepared passthrough, example CLI usage, and comprehensive unit/integration/e2e tests.

Changes

Prepared statements: author surface, runtime, drivers, adapters, and tests

Layer / File(s) Summary
AST and public prepared types
packages/2-sql/4-lanes/relational-core/src/ast/*, packages/2-sql/5-runtime/src/prepared/*
Add PreparedParamRef, AnyParamRef, LoweredParam, LimitOffsetValue, and public prepared-statement types (PreparedStatement, ParamSpec, Declaration, ParamsFromDeclaration).
AST rewrite/fold/collect propagation
packages/2-sql/4-lanes/relational-core/src/ast/*
Thread prepared-param-ref through rewrites, folds, visitors, insert/update handling, and param collection (expression-valued LIMIT/OFFSET supported).
Codec/Expression & builder pagination
packages/2-sql/4-lanes/relational-core/src/expression.ts, sql-builder/src/*
Export CodecTypesBase/CodecValue, extend pagination types to accept expression values (PaginationValue/LimitOffsetValue) and convert runtime inputs to expressions when needed.
Param-ref mutator & ordered refs
middleware/param-ref-mutator.ts, ast/util.ts
Broaden mutator to AnyParamRef, update collectOrderedParamRefs and entries() to handle literal vs prepared bind slots.
Decoding/encoding refactor
packages/2-sql/5-runtime/src/codecs/*
Export DecodeContext, build decode context from AST, change decodeRow to accept DecodeContext; derive per-param ParamMetadata from AST and add encodeParamsWithMetadata.
Plan lowering and SqlExecutionPlan
packages/2-sql/5-runtime/src/lower-sql-plan.ts, sql-execution-plan.ts
Require plan.ast, unwrap literal lowered slots for ad-hoc execute, and throw on bind slots encountered on ad-hoc path.
Prepared bind-site & encoding helpers
packages/2-sql/5-runtime/src/prepared/*
Add buildBindSiteParams, BindSiteExpression, resolvePreparedSlotValues, encodePreparedParams, PreparedStatementImpl, and related internals.
SqlRuntime surface & streaming
packages/2-sql/5-runtime/src/sql-runtime.ts
Add Runtime.prepare, RuntimeQueryable.executePrepared, implement prepared execution path, streamRows() centralization, handle WeakMap for prepared handles, and transaction/connection wrappers.
Adapters & SQL renderers
packages/3-targets/*/src/core/*, packages/3-targets/*/src/core/sql-renderer.ts
Emit LoweredParam[], add prepared-param-ref rendering, support expression-valued LIMIT/OFFSET in renderers, and update adapter tests to expect literal/bind slot shapes.
Drivers: Postgres & SQLite
packages/3-targets/7-drivers/postgres/*, packages/3-targets/7-drivers/sqlite/*
Postgres: add NamedCursor, driver preparedStatements option, executePrepared with per-driver handle allocation/retry; SQLite: add executePrepared passthrough on connection/transaction/driver.
Client prepare APIs
packages/3-extensions/postgres/src/runtime/postgres.ts, packages/3-extensions/sqlite/src/runtime/sqlite.ts
Add prepare(...) method on PostgresClient/SqliteClient delegating to runtime.prepare and adapting callback signature.
Examples & CLI
examples/prisma-next-demo*/src/queries/*, examples/*/src/main.ts
Add getUserByEmailPrepared helpers and user-by-email-prepared CLI commands demonstrating prepared-statement reuse.
Tests & test-utils
packages/*/test/*, test/e2e/*, test/utils/src/*
Add extensive unit, driver integration, named-cursor wire tests, and e2e tests for Postgres/SQLite prepared statements; add stubAst, litParams/bindParams helpers and package exports; update many existing tests to the new decode/context and lowered-param shapes.

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

Suggested reviewers:

  • saevarb

Poem:

"A little rabbit hops with glee,
I threaded params and AST with tea,
Prepared the plan, then watched it run,
From author, runtime, driver—done.
🍀🐇"

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch prepared-statements-impl

@pkg-pr-new

pkg-pr-new Bot commented May 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/extension-cipherstash

npm i https://pkg.pr.new/prisma/prisma-next/@prisma-next/extension-cipherstash@444

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 634c6cd

@SevInf
SevInf force-pushed the prepared-statements-impl branch 6 times, most recently from 3c3d708 to f4669d9 Compare May 15, 2026 18:10
@SevInf
SevInf marked this pull request as ready for review May 15, 2026 18:19
@SevInf
SevInf requested a review from a team as a code owner May 15, 2026 18:19

@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.

🧹 Nitpick comments (3)
packages/2-sql/5-runtime/test/marker-verification.test.ts (1)

94-100: ⚡ Quick win

Make executePrepared fail fast in this non-prepared marker suite.

Line 94 currently returns a successful async iterator, so an unintended switch to prepared execution could pass silently in this suite.

Suggested patch
-  const executePrepared = vi.fn().mockImplementation(async function* () {
-    yield {} as Record<string, unknown>;
-  });
+  const executePrepared = vi
+    .fn()
+    .mockRejectedValue(new Error('executePrepared not used in this test'));
🤖 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/test/marker-verification.test.ts` around lines 94 -
100, The test's executePrepared mock currently yields an empty result, so if
code accidentally switches to prepared execution this suite will still pass;
update the executePrepared mock in marker-verification.test.ts (the
executePrepared vi.fn() used alongside execute and query) to fail fast — either
make the mock implementation throw immediately or return an async iterator that
throws on first iteration — so any unintended prepared-path activation causes
the test to fail.
packages/2-sql/5-runtime/test/prepared.types.test-d.ts (1)

27-27: ⚡ Quick win

Replace deprecated expectTypeOf(...).toMatchTypeOf(...) matcher usage.

Line 27 and Line 67 use toMatchTypeOf, which is deprecated in this repo’s test-d.ts policy. Please switch to toExtend/toEqualTypeOf depending on intent.

♻️ Suggested update
-  expectTypeOf<Decl>().toMatchTypeOf<Declaration<FixtureCT>>();
+  expectTypeOf<Decl>().toExtend<Declaration<FixtureCT>>();
...
-  expectTypeOf(ps.execute(runtime, { userId: 7 })).toMatchTypeOf<AsyncIterable<Row>>();
+  expectTypeOf(ps.execute(runtime, { userId: 7 })).toExtend<AsyncIterable<Row>>();

As per coding guidelines: "**/*.test-d.ts: Do not use the deprecated toMatchTypeOf() matcher in Vitest's expectTypeOf API. Use toExtend() ... and toEqualTypeOf<T>() for exact matches."

Also applies to: 67-67

🤖 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/test/prepared.types.test-d.ts` at line 27, Replace
the deprecated matcher call
expectTypeOf<Decl>().toMatchTypeOf<Declaration<FixtureCT>>() (and the other
occurrence using toMatchTypeOf) with the repo-approved matcher: use
expectTypeOf<Decl>().toEqualTypeOf<Declaration<FixtureCT>>() if you need an
exact type equality, or use
expectTypeOf<Decl>().toExtend<Declaration<FixtureCT>>() if you intend a
structural/subtype relationship; update both occurrences accordingly
(referencing the Decl type and Declaration<FixtureCT> generic to locate the
lines).
packages/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts (1)

39-40: ⚡ Quick win

Use parameterized query for multi-row INSERT.

The INSERT statement uses string concatenation to build VALUES, which static analysis flagged. While safe here (controlled local data), it violates the parameterized query principle. Use Postgres unnest() for a clean, fully parameterized multi-row insert.

🔒 Proposed fix using unnest pattern
-        const insertValues = Array.from({ length: 50 }, (_, i) => `(${i})`).join(', ');
-        await client.query(`insert into items (n) values ${insertValues}`);
+        const values = Array.from({ length: 50 }, (_, i) => i);
+        await client.query('insert into items (n) select * from unnest($1::int[])', [values]);
🤖 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/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts`
around lines 39 - 40, The test builds a multi-row INSERT via string
concatenation (insertValues) and executes it with client.query, which should be
converted to a fully parameterized query; replace the hand-built VALUES string
with a parameterized unnest-based insert (pass an array of numbers as a single
parameter and use unnest($1::int[]) in the INSERT INTO items (n) SELECT * FROM
unnest(...)) so the query uses client.query with parameters instead of string
interpolation, keeping the same 0..49 values.
🤖 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.

Nitpick comments:
In `@packages/2-sql/5-runtime/test/marker-verification.test.ts`:
- Around line 94-100: The test's executePrepared mock currently yields an empty
result, so if code accidentally switches to prepared execution this suite will
still pass; update the executePrepared mock in marker-verification.test.ts (the
executePrepared vi.fn() used alongside execute and query) to fail fast — either
make the mock implementation throw immediately or return an async iterator that
throws on first iteration — so any unintended prepared-path activation causes
the test to fail.

In `@packages/2-sql/5-runtime/test/prepared.types.test-d.ts`:
- Line 27: Replace the deprecated matcher call
expectTypeOf<Decl>().toMatchTypeOf<Declaration<FixtureCT>>() (and the other
occurrence using toMatchTypeOf) with the repo-approved matcher: use
expectTypeOf<Decl>().toEqualTypeOf<Declaration<FixtureCT>>() if you need an
exact type equality, or use
expectTypeOf<Decl>().toExtend<Declaration<FixtureCT>>() if you intend a
structural/subtype relationship; update both occurrences accordingly
(referencing the Decl type and Declaration<FixtureCT> generic to locate the
lines).

In
`@packages/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts`:
- Around line 39-40: The test builds a multi-row INSERT via string concatenation
(insertValues) and executes it with client.query, which should be converted to a
fully parameterized query; replace the hand-built VALUES string with a
parameterized unnest-based insert (pass an array of numbers as a single
parameter and use unnest($1::int[]) in the INSERT INTO items (n) SELECT * FROM
unnest(...)) so the query uses client.query with parameters instead of string
interpolation, keeping the same 0..49 values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 6bf96e58-b1ba-448b-be29-73071509aad2

📥 Commits

Reviewing files that changed from the base of the PR and between 334168f and f4669d9.

📒 Files selected for processing (83)
  • docs/architecture docs/adrs/ADR 210 - Prepared Statements - Author Surface and Driver SPI.md
  • examples/prisma-next-demo-sqlite/src/main.ts
  • examples/prisma-next-demo-sqlite/src/queries/get-user-by-email-prepared.ts
  • examples/prisma-next-demo/src/main.ts
  • examples/prisma-next-demo/src/queries/get-user-by-email-prepared.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/types.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/util.ts
  • packages/2-sql/4-lanes/relational-core/src/expression.ts
  • packages/2-sql/4-lanes/relational-core/src/middleware/param-ref-mutator.ts
  • packages/2-sql/4-lanes/relational-core/src/sql-execution-plan.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/2-sql/4-lanes/relational-core/test/middleware/param-ref-mutator.test.ts
  • packages/2-sql/4-lanes/relational-core/test/sql-execution-plan.types.test-d.ts
  • packages/2-sql/4-lanes/relational-core/test/utils.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/builder-base.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/query-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/scope.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/grouped-query.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/select-query.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/shared.ts
  • packages/2-sql/5-runtime/src/codecs/decoding.ts
  • packages/2-sql/5-runtime/src/codecs/encoding.ts
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/5-runtime/src/lower-sql-plan.ts
  • packages/2-sql/5-runtime/src/middleware/budgets.ts
  • packages/2-sql/5-runtime/src/prepared/bind-site-params.ts
  • packages/2-sql/5-runtime/src/prepared/encode-prepared.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/codec-async.test.ts
  • packages/2-sql/5-runtime/test/codec-decode-ctx.test.ts
  • packages/2-sql/5-runtime/test/content-hash.test.ts
  • packages/2-sql/5-runtime/test/decode-error-passthrough.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/prepared.test.ts
  • packages/2-sql/5-runtime/test/prepared.types.test-d.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-family-adapter.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/cipherstash/src/middleware/bulk-encrypt.ts
  • packages/3-extensions/cipherstash/test/helpers.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering-equality.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering-text-search.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering.test.ts
  • packages/3-extensions/postgres/src/runtime/postgres.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-aggregate.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-meta.ts
  • packages/3-extensions/sql-orm-client/src/where-binding.ts
  • packages/3-extensions/sql-orm-client/test/query-plan-aggregate.test.ts
  • packages/3-extensions/sql-orm-client/test/query-plan-select.test.ts
  • packages/3-extensions/sql-orm-client/test/raw-compiled-query.test.ts
  • packages/3-extensions/sqlite/src/runtime/sqlite.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/operations/data-transform.ts
  • packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts
  • packages/3-targets/6-adapters/postgres/test/adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/data-transform.test.ts
  • packages/3-targets/6-adapters/sqlite/src/core/adapter.ts
  • packages/3-targets/6-adapters/sqlite/test/adapter.test.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/7-drivers/postgres/src/named-cursor.ts
  • packages/3-targets/7-drivers/postgres/src/postgres-driver.ts
  • packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.integration.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.test.ts
  • packages/3-targets/7-drivers/postgres/test/named-cursor.test.ts
  • packages/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts
  • packages/3-targets/7-drivers/postgres/vitest.config.ts
  • packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts
  • test/e2e/framework/test/runtime.prepared.test.ts
  • test/e2e/framework/test/sqlite/prepared.test.ts
  • test/utils/package.json
  • test/utils/src/exports/index.ts
  • test/utils/src/lowered-params.ts
  • test/utils/tsdown.config.ts

@SevInf
SevInf force-pushed the prepared-statements-impl branch from f4669d9 to 5a0faed Compare May 18, 2026 12:09
paramCount: number,
): readonly ParamMetadata[] {
if (ast === undefined) {
return new Array(paramCount).fill(NO_METADATA);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return new Array(paramCount).fill(NO_METADATA);
return Array.from({ length: paramCount }).fill(NO_METADATA);

Comment on lines +35 to +42
return Array.from({ length: paramCount }, (_, i): ParamMetadata => {
const ref = refs[i];
if (!ref) return NO_METADATA;
if (ref.kind === 'prepared-param-ref') {
return { codec: { codecId: ref.codecId }, name: ref.name };
}
return { codec: ref.codec, name: ref.name };
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is collectOrderedParamRefs expected to return paramCount refs? could we map over its result instead?

const stream = runWithMiddleware<SqlExecutionPlan, Record<string, unknown>>(
exec,
this.middleware,
this.ctx,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this used to use execMiddlewareCtx before extracting streamRows

const self = this;
const signal = options?.signal;
const codecCtx: SqlCodecCallContext = signal === undefined ? {} : { signal };
const execMiddlewareCtx = signal === undefined ? self.ctx : { ...self.ctx, signal };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we have a way to populate scope here based on the type of queryable?

@SevInf
SevInf force-pushed the prepared-statements-impl branch from 5a0faed to 54b849a Compare May 19, 2026 09:34

@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/src/postgres-driver.ts`:
- Around line 63-69: The handle allocator currently globals prepared statement
names per driver (createHandleAllocator / HandleAllocator) causing cross-client
collisions; change it to store handles per physical client by replacing the
single incrementing `next` with a per-client map (e.g.,
WeakMap<Client|PoolClient, string>) and move the lookup/mint logic to after you
acquire the concrete client for execution so that `request.handle` is resolved
per-client (lookup in WeakMap, mint a new per-client name if missing) before
checking `client.parsedStatements`/executing the PreparedStatement; update all
uses (including the other occurrences noted at lines ~148-156) to consult this
per-client mapping rather than a single driver-scoped counter.

In
`@packages/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts`:
- Around line 26-28: The test allocates the dev DB via createDevDatabase()
before creating/connecting the pg.Client but doesn't guarantee database.close()
runs if client.connect() or client.end() throws; ensure database.close() is
always called by moving the try/finally to start immediately after
createDevDatabase() (or wrap createDevDatabase() in its own try/finally), and in
the finally always call await database.close() regardless of client state,
handling/rethrowing client.end() failures separately so a rejected client.end()
cannot short-circuit database.close(); update the code paths around
client.connect(), client.end(), and database.close() (referencing
createDevDatabase, client.connect, client.end, database.close) to enforce this
cleanup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 2b0e7cad-595b-417d-8a9f-8499de41df8c

📥 Commits

Reviewing files that changed from the base of the PR and between 5a0faed and 54b849a.

📒 Files selected for processing (83)
  • docs/architecture docs/adrs/ADR 210 - Prepared Statements - Author Surface and Driver SPI.md
  • examples/prisma-next-demo-sqlite/src/main.ts
  • examples/prisma-next-demo-sqlite/src/queries/get-user-by-email-prepared.ts
  • examples/prisma-next-demo/src/main.ts
  • examples/prisma-next-demo/src/queries/get-user-by-email-prepared.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/types.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/util.ts
  • packages/2-sql/4-lanes/relational-core/src/expression.ts
  • packages/2-sql/4-lanes/relational-core/src/middleware/param-ref-mutator.ts
  • packages/2-sql/4-lanes/relational-core/src/sql-execution-plan.ts
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/2-sql/4-lanes/relational-core/test/middleware/param-ref-mutator.test.ts
  • packages/2-sql/4-lanes/relational-core/test/sql-execution-plan.types.test-d.ts
  • packages/2-sql/4-lanes/relational-core/test/utils.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/builder-base.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/query-impl.ts
  • packages/2-sql/4-lanes/sql-builder/src/scope.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/grouped-query.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/select-query.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/shared.ts
  • packages/2-sql/5-runtime/src/codecs/decoding.ts
  • packages/2-sql/5-runtime/src/codecs/encoding.ts
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/5-runtime/src/lower-sql-plan.ts
  • packages/2-sql/5-runtime/src/middleware/budgets.ts
  • packages/2-sql/5-runtime/src/prepared/bind-site-params.ts
  • packages/2-sql/5-runtime/src/prepared/encode-prepared.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/codec-async.test.ts
  • packages/2-sql/5-runtime/test/codec-decode-ctx.test.ts
  • packages/2-sql/5-runtime/test/content-hash.test.ts
  • packages/2-sql/5-runtime/test/decode-error-passthrough.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/prepared.test.ts
  • packages/2-sql/5-runtime/test/prepared.types.test-d.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-family-adapter.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/cipherstash/src/middleware/bulk-encrypt.ts
  • packages/3-extensions/cipherstash/test/helpers.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering-equality.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering-text-search.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering.test.ts
  • packages/3-extensions/postgres/src/runtime/postgres.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-aggregate.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-meta.ts
  • packages/3-extensions/sql-orm-client/src/where-binding.ts
  • packages/3-extensions/sql-orm-client/test/query-plan-aggregate.test.ts
  • packages/3-extensions/sql-orm-client/test/query-plan-select.test.ts
  • packages/3-extensions/sql-orm-client/test/raw-compiled-query.test.ts
  • packages/3-extensions/sqlite/src/runtime/sqlite.ts
  • packages/3-targets/3-targets/postgres/src/core/migrations/operations/data-transform.ts
  • packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts
  • packages/3-targets/6-adapters/postgres/test/adapter.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/data-transform.test.ts
  • packages/3-targets/6-adapters/sqlite/src/core/adapter.ts
  • packages/3-targets/6-adapters/sqlite/test/adapter.test.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/7-drivers/postgres/src/named-cursor.ts
  • packages/3-targets/7-drivers/postgres/src/postgres-driver.ts
  • packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.integration.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.test.ts
  • packages/3-targets/7-drivers/postgres/test/named-cursor.test.ts
  • packages/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts
  • packages/3-targets/7-drivers/postgres/vitest.config.ts
  • packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts
  • test/e2e/framework/test/runtime.prepared.test.ts
  • test/e2e/framework/test/sqlite/prepared.test.ts
  • test/utils/package.json
  • test/utils/src/exports/index.ts
  • test/utils/src/lowered-params.ts
  • test/utils/tsdown.config.ts
✅ Files skipped from review due to trivial changes (2)
  • packages/3-targets/7-drivers/postgres/vitest.config.ts
  • packages/2-sql/5-runtime/test/intercept-decoding.test.ts
🚧 Files skipped from review as they are similar to previous changes (66)
  • examples/prisma-next-demo/src/queries/get-user-by-email-prepared.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-meta.ts
  • packages/2-sql/5-runtime/test/marker-vs-intercept-ordering.test.ts
  • test/utils/src/exports/index.ts
  • packages/2-sql/4-lanes/relational-core/src/sql-execution-plan.ts
  • packages/2-sql/5-runtime/src/lower-sql-plan.ts
  • packages/2-sql/4-lanes/relational-core/test/sql-execution-plan.types.test-d.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/driver-types.ts
  • packages/2-sql/4-lanes/relational-core/test/utils.ts
  • packages/2-sql/5-runtime/test/content-hash.test.ts
  • packages/2-sql/5-runtime/src/prepared/bind-site-params.ts
  • packages/2-sql/5-runtime/test/runtime-ctx-passthrough.test.ts
  • packages/2-sql/5-runtime/test/sql-family-adapter.test.ts
  • packages/3-extensions/cipherstash/test/helpers.test.ts
  • packages/3-extensions/cipherstash/test/operator-lowering-text-search.test.ts
  • test/utils/package.json
  • packages/2-sql/4-lanes/relational-core/test/ast/driver-types.test.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/builder-base.ts
  • test/e2e/framework/test/sqlite/prepared.test.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/grouped-query.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.test.ts
  • packages/3-extensions/sql-orm-client/test/query-plan-select.test.ts
  • packages/2-sql/5-runtime/src/exports/index.ts
  • packages/2-sql/4-lanes/relational-core/src/ast/util.ts
  • packages/2-sql/5-runtime/src/prepared/encode-prepared.ts
  • packages/3-targets/7-drivers/postgres/test/named-cursor.test.ts
  • packages/3-extensions/sql-orm-client/test/raw-compiled-query.test.ts
  • test/utils/src/lowered-params.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/shared.ts
  • packages/2-sql/5-runtime/src/middleware/budgets.ts
  • packages/2-sql/4-lanes/relational-core/src/middleware/param-ref-mutator.ts
  • packages/3-extensions/cipherstash/test/operator-lowering-equality.test.ts
  • packages/3-extensions/sqlite/src/runtime/sqlite.ts
  • packages/3-targets/6-adapters/postgres/test/adapter.test.ts
  • packages/2-sql/5-runtime/src/prepared/prepared-statement.ts
  • packages/2-sql/5-runtime/test/prepared.types.test-d.ts
  • packages/3-extensions/cipherstash/test/operator-lowering.test.ts
  • packages/3-extensions/sql-orm-client/src/query-plan-aggregate.ts
  • packages/2-sql/5-runtime/src/prepared/types.ts
  • packages/2-sql/5-runtime/test/utils.ts
  • packages/2-sql/4-lanes/sql-builder/src/scope.ts
  • packages/2-sql/5-runtime/test/sql-runtime-abort.test.ts
  • packages/2-sql/4-lanes/relational-core/src/expression.ts
  • packages/3-targets/6-adapters/sqlite/test/adapter.test.ts
  • packages/2-sql/5-runtime/test/async-iterable-result.test.ts
  • packages/3-targets/7-drivers/postgres/test/driver.prepared.integration.test.ts
  • packages/3-targets/6-adapters/postgres/test/migrations/data-transform.test.ts
  • packages/2-sql/5-runtime/test/decode-error-passthrough.test.ts
  • examples/prisma-next-demo/src/main.ts
  • packages/2-sql/4-lanes/sql-builder/src/types/select-query.ts
  • packages/2-sql/5-runtime/test/codec-decode-ctx.test.ts
  • packages/3-extensions/postgres/src/runtime/postgres.ts
  • packages/3-targets/7-drivers/sqlite/src/sqlite-driver.ts
  • packages/2-sql/4-lanes/sql-builder/src/runtime/query-impl.ts
  • packages/3-targets/7-drivers/postgres/src/named-cursor.ts
  • packages/3-targets/7-drivers/postgres/src/exports/runtime.ts
  • packages/3-targets/7-drivers/postgres/test/driver.errors.test.ts
  • packages/2-sql/5-runtime/test/codec-async.test.ts
  • packages/2-sql/5-runtime/test/sql-runtime.test.ts
  • packages/2-sql/5-runtime/src/codecs/decoding.ts
  • examples/prisma-next-demo-sqlite/src/main.ts
  • packages/2-sql/4-lanes/relational-core/test/middleware/param-ref-mutator.test.ts
  • packages/2-sql/5-runtime/test/prepared.test.ts
  • test/e2e/framework/test/runtime.prepared.test.ts
  • packages/3-targets/6-adapters/sqlite/src/core/adapter.ts
  • packages/3-targets/6-adapters/postgres/src/core/sql-renderer.ts

Comment on lines +63 to +69
function createHandleAllocator(): HandleAllocator {
// Driver-scoped so a single PreparedStatement reused across multiple
// Connections/Transactions of the same driver always sees one handle.
let next = 1;
return {
mint: () => `pn_${next++}`,
};

@coderabbitai coderabbitai Bot May 19, 2026 •

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.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Store prepared handles per physical client, not one per driver.

This caches a single statement name in request.handle, which breaks pooled reuse. If the same PreparedStatement is first executed on client A as pn_1 and on client B as pn_2, the shared slot can only remember one of them; the next execute on the other client misses parsedStatements, falls into 26000, and keeps churning names/retries instead of actually reusing the prepared plan. The opaque handle needs to carry per-client state (for example, a WeakMap<Client | PoolClient, string>) and the lookup/mint has to happen after acquiring the concrete client for this execution.

Also applies to: 148-156

🤖 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/3-targets/7-drivers/postgres/src/postgres-driver.ts` around lines 63
- 69, The handle allocator currently globals prepared statement names per driver
(createHandleAllocator / HandleAllocator) causing cross-client collisions;
change it to store handles per physical client by replacing the single
incrementing `next` with a per-client map (e.g., WeakMap<Client|PoolClient,
string>) and move the lookup/mint logic to after you acquire the concrete client
for execution so that `request.handle` is resolved per-client (lookup in
WeakMap, mint a new per-client name if missing) before checking
`client.parsedStatements`/executing the PreparedStatement; update all uses
(including the other occurrences noted at lines ~148-156) to consult this
per-client mapping rather than a single driver-scoped counter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is incorrect. pg handles reparsing of multiple clients transparently via name property on the statement.

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.

@SevInf, you're right — I apologize for the incorrect review. Each pg Client maintains its own parsedStatements map, so when a connection that hasn't seen pn_1 executes a named query, pg (and NamedCursor.submitNamed) automatically sends a Parse message for that connection. The single driver-scoped name in request.handle is the correct design: it serves as a stable statement identity, and each physical connection lazily parses it on first use without any cross-client collision. There's no need for per-client name tracking.


✏️ Learnings added
Learnt from: SevInf
Repo: prisma/prisma-next PR: 444
File: packages/3-targets/7-drivers/postgres/src/postgres-driver.ts:63-69
Timestamp: 2026-05-19T17:03:30.809Z
Learning: In the prisma/prisma-next Postgres driver (`packages/3-targets/7-drivers/postgres/src/postgres-driver.ts`), a single driver-scoped prepared-statement name (e.g. `pn_1`) stored in `request.handle` is safe for use across pooled/multiple `pg` clients. Each `pg` `Client` maintains its own `parsedStatements` map; if the name is absent from a given connection's map, `pg` (and `NamedCursor.submitNamed`) automatically sends a Parse message for that connection. Do NOT flag this as a cross-client collision bug — the per-client lazy-parse behavior is intentional and correct.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: wmadden
Repo: prisma/prisma-next PR: 38
File: packages/2-sql/3-tooling/family/src/core/migrations/plan-helpers.ts:40-47
Timestamp: 2025-12-26T23:02:40.679Z
Learning: In Prisma-next's TypeScript codebase, prefer using well-established utility libraries (e.g., Lodash) rather than building custom utilities for complex object operations such as deep freezing or deep cloning. Favor reliable, battle-tested functions and ensure dependencies are reviewed for tree-shaking and bundle size. If a lightweight utility suffices, consider modern native approaches or smaller libs.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 191
File: packages/1-framework/3-tooling/cli/src/commands/contract-emit.ts:5-5
Timestamp: 2026-03-01T13:54:21.863Z
Learning: In the Prisma-next repository, prefer importing and using 'pathe' over the built-in 'node:path' module for path operations across the codebase (including CLI commands and tooling files). Apply this in TypeScript files, replacing imports from 'node:path' with 'pathe' and adjusting API usage accordingly. Ensure consistent usage across all modules and update any affected tests or tooling imports when refactoring.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 234
File: packages/2-sql/4-lanes/sql-lane/test/rich-mutation.test.ts:2-2
Timestamp: 2026-03-23T10:01:15.075Z
Learning: In the prisma/prisma-next repo, prefer using `pathe` over Node’s built-in `node:path`. For any TypeScript file (including tests, test helpers, and integration tooling) replace imports like `import { dirname, join } from 'node:path'` with `import { dirname, join } from 'pathe'`—especially when code reads files/fixtures from disk.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 294
File: packages/2-mongo-family/2-query/query-ast/src/read-plan.ts:4-10
Timestamp: 2026-04-04T10:08:34.220Z
Learning: In prisma/prisma-next, don’t flag declaration-emit/typecheck warnings/errors when a file uses an intentional nominal/branding pattern with a non-exported `declare const <brand>: unique symbol` as a computed property key on an exported interface (e.g., `readonly [__mongoReadPlanRow]: ...` / `readonly [aggregateResultBrand]: ...`). The `unique symbol` must remain unexported to prevent external forging, while the branded property key staying on the exported interface provides compile-time discrimination. If the build correctly emits declaration files for this pattern, treat it as intentional rather than a declaration-emit error.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 293
File: packages/1-framework/1-core/shared/contract/src/canonicalization.ts:203-216
Timestamp: 2026-04-04T12:19:05.250Z
Learning: In the prisma/prisma-next repository, do not treat `Array.prototype.sort` comparators as “potentially non-deterministic” solely because the comparator does not include explicit tie-breaking keys. This is because the repo’s required runtime is Node >= 24, where `Array.prototype.sort` is stable (equal elements retain their original relative order via a stable sort such as TimSort). Therefore, equal-comparing elements should remain deterministic without additional tie-break logic.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 334
File: packages/2-mongo-family/9-family/src/core/control-instance.ts:204-228
Timestamp: 2026-04-13T15:54:52.337Z
Learning: When reviewing TypeScript code in this repo, do not assume a property is potentially `undefined` at a call site just because an arktype schema definition uses the DSL syntax `'key?': 'type'` (a quoted string key with a trailing `?`). This DSL notation is not the same as TypeScript optional properties (`key?: type`). To determine whether `key` is truly optional/undefined-capable, verify the actual exported TypeScript type declaration (e.g., `contract-types.ts`) and the runtime validation schema (e.g., `validate-contract.ts`) for that property; only then should the review flag call-site handling for potential `undefined`.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 339
File: test/integration/test/cli.init-templates.e2e.test.ts:96-96
Timestamp: 2026-04-15T19:33:48.733Z
Learning: In prisma/prisma-next, when writing tests that run TypeScript compilation (e.g., via `tsc --noEmit`), avoid hardcoded timeout numbers (such as `30_000`). Instead, use `prisma-next/test-utils` timeout helpers—specifically `timeouts.typeScriptCompilation` (implemented in `test/utils/src/timeouts.ts`) for `tsc` compilation scenarios. Use `timeouts.spinUpPpgDev` for PostgreSQL server startup and `timeouts.databaseOperation` for database operation scenarios.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 364
File: packages/3-targets/3-targets/postgres/src/core/migrations/operations/data-transform.ts:45-50
Timestamp: 2026-04-22T11:03:41.124Z
Learning: In prisma/prisma-next (including packages/3-targets), avoid code review flags for missing “empty-array guards” or for not enforcing non-empty tuple types on API option types. For example, for a field typed like `DataTransformOptions.run: DataTransformClosure | readonly DataTransformClosure[]`, prefer trusting callers and the existing type contracts rather than requiring extra defensive type narrowing or runtime non-emptiness checks/guards for empty/edge-case inputs.

Learnt from: saevarb
Repo: prisma/prisma-next PR: 394
File: packages/1-framework/3-tooling/migration/src/graph-ops.ts:50-54
Timestamp: 2026-04-29T12:44:59.376Z
Learning: In TypeScript overload implementations, an internal “implementation-only” cast (e.g., `state as unknown as <ReturnType>`) can be safe and intentional when the public overload signatures and their structural typing prevent callers from reaching the implementation with an incompatible type. In these cases, reviewers should not flag the cast as a blind/unsafe cast, since compile-time overload enforcement substitutes for a runtime type guard. Don’t require an added `typeof`/runtime check solely to silence the cast when the overload design already prevents invalid inputs.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 417
File: packages/3-extensions/sql-orm-client/src/types.ts:309-318
Timestamp: 2026-05-08T17:07:07.145Z
Learning: In prisma/prisma-next code, prefer `ifDefined` from `prisma-next/utils/defined` for conditional object spreads instead of inline ternary-based spreads. For example, when building option objects for `ParamRef.of` (or similar codec/param construction), wrap optional values with `ifDefined(...)` so that the spread only includes the property when the value is defined, improving readability and avoiding “{...cond ? {a: b} : {}}”-style patterns. Ensure you import `ifDefined` from `prisma-next/utils/defined` and use it consistently for these conditional spreads.

Learnt from: wmadden
Repo: prisma/prisma-next PR: 474
File: packages/2-mongo-family/9-family/src/core/mongo-target-descriptor.ts:68-74
Timestamp: 2026-05-11T05:34:02.685Z
Learning: When reviewing code in this repo (prisma/prisma-next) for the `doc-maintenance` rule/no-transient-artefacts guideline, do not flag Linear ticket IDs in source-code comments (e.g., `TML-2397`) as violations. The rule should only consider truly transient artefacts as forbidden—specifically milestone IDs, acceptance-criteria IDs (e.g., `AC11`), and sub-spec section references (e.g., `§ 3.2`).

Learnt from: wmadden
Repo: prisma/prisma-next PR: 485
File: test/integration/test/cli.init-facade-imports.e2e.test.ts:14-14
Timestamp: 2026-05-12T03:36:07.175Z
Learning: In this repo, the doc-maintenance rule allows stable reference IDs in source-code comments—e.g., Linear ticket IDs matching `TML-*` (such as `TML-2485`, `TML-2397`) and ADR references like `ADR 211`. Do not flag `TML-*` ticket ID references in code comments as violations. Instead, violations are limited to transient artifacts such as `projects/<x>/...` paths, milestone-task IDs like `T1.7` / `T2.5.3`, milestone acceptance-criteria codes like `AM12` / `AC-13`, and prose attributions like `M2 review`, `out of scope`, or `sub-spec § 4`—flag those when found in comments.

Comment on lines +26 to +28
const database = await createDevDatabase();
const client = new pg.Client({ connectionString: database.connectionString });
await client.connect();

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Always run database.close() even when client setup/teardown fails.

database is allocated before client.connect(), but the try/finally starts after that call, and the finally also short-circuits if client.end() rejects. Either failure path skips database.close(), which can leak the dev DB and destabilize later integration tests.

Cleanup sketch
-      const database = await createDevDatabase();
-      const client = new pg.Client({ connectionString: database.connectionString });
-      await client.connect();
+      const database = await createDevDatabase();
+      const client = new pg.Client({ connectionString: database.connectionString });

-      let parseCompleteCount = 0;
-      // biome-ignore lint/suspicious/noExplicitAny: pg.Connection internals are untyped
-      const connection = (client as any).connection;
-      connection.on('parseComplete', () => {
-        parseCompleteCount++;
-      });
-
       try {
+        await client.connect();
+        let parseCompleteCount = 0;
+        // biome-ignore lint/suspicious/noExplicitAny: pg.Connection internals are untyped
+        const connection = (client as any).connection;
+        connection.on('parseComplete', () => {
+          parseCompleteCount++;
+        });
+
         await client.query('create table items (id serial primary key, n int)');
         const insertValues = Array.from({ length: 50 }, (_, i) => `(${i})`).join(', ');
         await client.query(`insert into items (n) values ${insertValues}`);
@@
       } finally {
-        await client.end();
-        await database.close();
+        try {
+          await client.end();
+        } finally {
+          await database.close();
+        }
       }

Also applies to: 73-75

🤖 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/3-targets/7-drivers/postgres/test/named-cursor.wire.integration.test.ts`
around lines 26 - 28, The test allocates the dev DB via createDevDatabase()
before creating/connecting the pg.Client but doesn't guarantee database.close()
runs if client.connect() or client.end() throws; ensure database.close() is
always called by moving the try/finally to start immediately after
createDevDatabase() (or wrap createDevDatabase() in its own try/finally), and in
the finally always call await database.close() regardless of client state,
handling/rethrowing client.end() failures separately so a rejected client.end()
cannot short-circuit database.close(); update the code paths around
client.connect(), client.end(), and database.close() (referencing
createDevDatabase, client.connect, client.end, database.close) to enforce this
cleanup.

@aqrln aqrln mentioned this pull request May 19, 2026
5 tasks
@SevInf
SevInf force-pushed the prepared-statements-impl branch 2 times, most recently from 8f770b9 to 54b849a Compare May 19, 2026 17:02
Adds runtime.prepare() and db.prepare() author surfaces returning a
reusable PreparedStatement that captures lowered SQL once. The
executePrepared driver SPI receives { sql, params, handle }. Postgres
driver uses pg's name-keyed parsedStatements cache with pn_<n>
handles allocated lazily on first execute; streams via a custom
pg-cursor subclass that sends Parse+Bind for the named statement.
Stale-handle retry on SQLSTATE 26000 / 0A000 (deallocated name;
cached-plan invalid) mints a fresh handle and retries exactly once.
preparedStatements: false driver option falls back to one-shot
parameterized queries (PgBouncer transaction mode).

PreparedStatement.execute(target, params, options?) takes an explicit
RuntimeQueryable (Runtime / RuntimeConnection / RuntimeTransaction /
TransactionContext). The runtime hides the driver handle behind a
per-runtime WeakMap; the PreparedStatement public surface is pure data.
DecodeContext and ParamMetadata are cached at prepare time.

Tightens SqlExecutionPlan.ast to required; adds a stubAst() test helper
for fixtures that previously left ast undefined.

Signed-off-by: Serhii Tatarintsev <[email protected]>
@SevInf
SevInf force-pushed the prepared-statements-impl branch from 54b849a to 634c6cd Compare May 19, 2026 17:03
@SevInf
SevInf enabled auto-merge (squash) May 19, 2026 17:04
@SevInf
SevInf disabled auto-merge May 19, 2026 18:10
@SevInf
SevInf merged commit 975ab75 into main May 19, 2026
16 checks passed
@SevInf
SevInf deleted the prepared-statements-impl branch May 19, 2026 18:10
@wmadden wmadden mentioned this pull request May 20, 2026
wmadden added a commit that referenced this pull request May 20, 2026
## Version

**0.9.0 → 0.10.0**

Lockstep bump across all 82 workspace packages (`package.json` +
`pnpm-lock.yaml` workspace specifiers only).

Versioning policy:
[docs/oss/versioning.md](https://github.com/prisma/prisma-next/blob/main/docs/oss/versioning.md)

## Release notes (since 0.9.0)

No additional maintainer flags at pre-flight. Notable changes already on
`main` that consumers should plan for when moving to **0.10.0**:

- **Breaking — strict `storage.types` deserializer:** On-disk contract
snapshots must tag every `storage.types` entry with `kind`
(`codec-instance` / `postgres-enum`). Untagged codec triples no longer
load. Use the shipped upgrade skills (`prisma-next-upgrade` and
`prisma-next-extension-upgrade`, `0.9-to-0.10` entries +
`stamp-storage-types-kind.ts` codemod).
- **CLI:** Migration surface reorganized (`migrate` verb, `ref`
promoted, removed verbs redirect with suggestions); `--version` sourced
from `package.json`.
- **SQL:** Prepared statements primitive (#444).

## Publish trigger

**Merging this PR ships the release:** the push to `main` carries root
`version` **0.10.0**, the [Publish to
npm](https://github.com/prisma/prisma-next/blob/main/.github/workflows/publish.yml)
workflow publishes under dist-tag `latest`, and a matching GitHub
Release is created automatically. No separate dispatch step.

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

* **Chores**
* Released version 0.10.0 across the platform: core packages,
extensions, adapters, drivers, targets, tooling, examples, and test
fixtures updated for consistency.
* Updated internal dependency alignments and package manifests to match
the new release; no functional or script changes to examples or runtime
behavior.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/prisma/prisma-next/pull/545?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Will Madden <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants