Skip to content

Send SqlClient.batch as one libSQL batch - #10175

Merged
tim-smart merged 2 commits into
agent/nelson-effect-bot/634621d8d78ffrom
agent/effect-bot/libsql-native-batch
Oct 30, 2026
Merged

tim-smart merged 2 commits into
agent/nelson-effect-bot/634621d8d78ffrom
agent/effect-bot/libsql-native-batch

Conversation

@effect-bot

Copy link
Copy Markdown
Contributor

Implements Connection.executeBatch for @effect/sql-libsql, so SqlClient.batch runs as one libSQL batch instead of falling back to one statement at a time. Against a remote libSQL or Turso database that is one round trip instead of one per statement.

Stacked on #10147, which adds SqlClient.batch and the Connection.executeBatch hook. This PR targets #10147's branch so the diff shows only the libsql change; retarget it to v4/next-minor once #10147 merges.

Behavior

  • executeBatch calls sdk.batch(statements, "write") and returns each statement's ResultSet.rows. Core still applies each statement's row transforms, the current transformer, tracing and transaction routing.
  • Outside withTransaction, libSQL runs the batch as one write transaction. A failing statement fails the batch and nothing from it is kept. The "write" mode matches beginTransaction, so a batch with writes takes the write lock up front instead of upgrading partway through.
  • Inside withTransaction the connection holds a libSQL Transaction, whose batch runs in the open transaction and ignores the mode. A failing statement fails the batch, and the enclosing withTransaction rolls back as usual.

Tests

packages/sql/libsql/test/Client.integration.test.ts gets a new batch block that runs on :memory: clients:

  • "sends the statements in one libsql batch": per-statement rows, and exactly one SDK batch call.
  • "keeps nothing from a batch when a later statement fails": a duplicate-key failure in the second statement leaves the first insert rolled back.

Closes EFF-3161

@changeset-bot

changeset-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b20c509

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
@effect/sql-libsql Minor
effect Minor
@effect/opentelemetry Minor
@effect/vitest Minor
@effect/ai-anthropic Minor
@effect/ai-cloudflare Minor
@effect/ai-openai-compat Minor
@effect/ai-openai Minor
@effect/ai-openrouter Minor
@effect/ai-typesafe Minor
@effect/atom-react Minor
@effect/atom-solid Minor
@effect/atom-vue Minor
@effect/platform-browser Minor
@effect/platform-bun Minor
@effect/platform-deno Minor
@effect/platform-node-shared Minor
@effect/platform-node Minor
@effect/sql-clickhouse Minor
@effect/sql-d1 Minor
@effect/sql-mssql Minor
@effect/sql-mysql2 Minor
@effect/sql-pg Minor
@effect/sql-pglite Minor
@effect/sql-sqlite-bun Minor
@effect/sql-sqlite-do Minor
@effect/sql-sqlite-node Minor
@effect/sql-sqlite-react-native Minor
@effect/sql-sqlite-wasm Minor
@effect/docgen Minor
@effect/doctest Minor
@effect/graphql-generator Minor
@effect/openapi-generator Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tim-smart
tim-smart merged commit db739ec into agent/nelson-effect-bot/634621d8d78f Oct 30, 2026
10 checks passed
@tim-smart
tim-smart deleted the agent/effect-bot/libsql-native-batch branch October 30, 2026 02:37
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