Update vitest from 3.2.7 to 4.1.11 to pick up the fix for the
@vitest/mocker advisory: before 4.1.11, a client that can reach the dev
server can register a redirect mock pointing at any file and read that
file's contents. 4.1.11 checks the target against the dev server's
allowed files.
Vitest 4 moved Playwright browser support into a separate package, so
the wasm packages (`packages/wasm`, `sync/packages/wasm`) now depend on
`@vitest/browser-playwright` instead of `@vitest/browser`, and their
`vitest.config.ts` passes `provider: playwright()`.
Note: vitest 4 resolves its own vite 8.3.0, while our packages still use
vite ^7.3.5 for `vite build`, so both are installed.
Tests: `packages/common` tests pass on vitest 4.1.11. Native and browser
tests are left to CI.
Closes#9097
AggStep only had fast paths for integer sum and min/max, so sum() and
total() over floats, every avg() and every count() went through the generic
step. That step matches on the function again, re-reads every payload slot
and writes all of them back for each row. TPC-H Q1 runs seven of its eight
aggregates over 6M rows on that path.
The new fast paths cover a float or an integer below 2^52 added to a float
sum or avg total, and count. Integers below 2^52 convert to a float exactly,
like the non-split branch of SQLite's kahanBabuskaNeumaierStepInt64. Each
fast path produces the same payload as the generic step, which still handles
the first row, non-numeric values, larger integers, integer overflow and
totals that are no longer finite.
Tests: agg-functions/sum-large-float.sqltest covers the rounding error term,
float input after an integer overflow, integers on both sides of 2^52 after
floats in sum and avg, total() over integers, an infinite total and count
over mixed value types.
Vitest before 4.1.11 ships a @vitest/mocker that lets a client register a
redirect mock pointing at any file, and then read that file through the dev
server. Version 4.1.11 checks the target against the dev server's allowed
files.
Vitest 4 moved Playwright browser support into @vitest/browser-playwright, so
the wasm packages now depend on it and pass playwright() as the provider.
The message for LimboError::ReadOnly was "Error: Resource is read-only".
SQLite says "attempt to write a readonly database", which is what the
upstream tests and the JavaScript binding tests compare against.
Ever since the libSQL days, the batch API has had the same complaint:
you
could not get the result of each individual statement, and when a batch
failed you could not tell which statement failed — or what had already
taken effect. With Turso we have a blank slate, and it turns out the
protocol never was the limitation: a batch response carries complete
per-statement information (results, last insert rowid, error codes, and
the execution statistics `rows_read`, `rows_written`,
`query_duration_ms`; PROTOCOL.md §6.2, §8.4, §9.1). The drivers just
dropped it. This PR takes the opportunity to do it right.
Every driver now exposes one `batch()` API that returns everything the
protocol reports, per statement, in one HTTP round trip:
- **Per-statement results**: rows, affected row count, last insert
rowid, and the server-side execution statistics.
- **Failure visibility**: statements execute in order and stop at the
first failure; the error identifies the failing statement by index
*and* carries one entry per statement — the completed statement's
result, or null/None for the failing statement and the ones that never
ran. In a non-atomic batch the completed statements are committed, and
the caller can finally see exactly what took effect.
- **Atomic mode**: the transactional variant wraps the statements in
`BEGIN <mode>` / `COMMIT` with a conditional `ROLLBACK`, carried by
the
same single request.
Per driver:
- **JavaScript** (`serverless/javascript`, existing public API —
extended
compatibly): each `ResultSet` gains `lastInsertRowid`, `rowsRead`,
`rowsWritten`, `queryDurationMs`; the thrown `DatabaseError` gains
`batchIndex` and `batchResults`. `batch()` moves from the cursor
endpoint to a pipeline batch request because the cursor stream's
`step_end` does not carry the statistics. Non-atomic batches are now
gated on the previous statement succeeding — previously statements
after a failure kept executing server-side.
- **Rust** (new API, `bindings/rust` + `serverless/rust` in one commit
per the driver-parity rule): `Connection::batch` /
`Connection::transactional_batch`,
`BatchStatement`/`IntoBatchStatement`
inputs, `BatchResult` with stats accessors, and
`Error::BatchStatementFailed { index, error, results }`. The sync
driver shares the embedded `Connection`, so all three backends expose
the same API.
- **Python** (new API, `bindings/python` + `serverless/python` in one
commit): `Connection.batch(statements, mode=None)` on the DB-API
surface (sync, aio, and the sync-database driver via inheritance),
raising the classified DB-API exception with `batch_index` and
`batch_results` attributes.
The parity requirement itself is codified first, in
`serverless/conformance/differential/README.md` ("Driver API parity")
with a pointer from the AGENTS.md core principles.
**Deliberately skipped: Go.** The Go serverless driver is a plain
`database/sql` driver, and `database/sql` has no batch surface, so it is
less obvious what to do there: libsql-client-go's precedent is splitting
multi-statement SQL client-side (with a vendored ANTLR SQLite parser)
inside `Exec`, while the alternative is a driver-specific `Batch` API
outside the standard interface. That trade-off deserves its own
discussion and PR.
The batch behavior is property-tested: a `param_batch` operation in the
shared differential vocabulary (`spec/ops.json`) generates 1-4
parameterized statements — including planted failures and atomic modes —
and all three language harnesses (fast-check, hypothesis, hegel) assert
that the embedded and serverless drivers agree on every statement's
result, the failing index, and the partial results carried by the error.
Building those harnesses caught two real driver bugs before the tests
ever ran: the embedded JS driver had no batch error surface at all, and
the embedded Rust driver reported the connection's stale change counter
for row-returning statements inside a batch.
Follow-ups, out of scope here:
- Whether the JS `compat` (libsql-compat) layer should surface the new
per-statement `ResultSet` fields on success; it is kept libsql-shaped
here (the error path does preserve `batchIndex`/`batchResults`).
- Driver-wide preservation of `extended_code` on errors (today only the
Python serverless `ServerError` keeps it).
- A batch entry containing multi-statement SQL ("a; b") errors on the
embedded drivers but the server prepares only the first statement — an
embedded/serverless divergence worth its own discussion.
Also rides along in the JS commit: four env-gated integration tests
still
asserted positional access on expanded rows, which f52724d45 removed on
purpose; CI never runs those tests, so they had drifted.
Tested against a live libsql-server and against Turso Cloud: Rust 44
unit + 58 conformance tests plus the hegel parity property, Python 73
serverless + 236 embedded plus the hypothesis parity property,
JavaScript 42 integration tests plus the fast-check parity property, and
protocol-level coverage asserting a parameterized multi-statement batch
in a single pipeline POST.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Closes#8535
Raise the Vitest and Vite minimum versions and refresh both npm and Yarn locks. This also updates the vulnerable js-yaml, nanoid, postcss, and ws transitive resolutions named by the security report.
Tests: npm ci --ignore-scripts; yarn install --immutable --mode=skip-build; yarn workspace @tursodatabase/database-common test; npm audit --package-lock-only
Co-authored-by: pedro muniz <pedro.muniz.carlo@gmail.com>
Parameterized batches could produce different effects across embedded and
serverless drivers when a later bind value was invalid. Embedded Rust also
allowed cloned connections to interleave work with a batch, and managed
batches allowed transaction-control statements to escape their wrapper.
Rollback failures were hidden, while serverless Rust could retain a stale
last-insert rowid when COMMIT failed after a successful insert.
Validate every batch input before execution, reject transaction-control SQL
before opening a managed transaction, and hold an operation-wide gate for
embedded Rust batches. Preserve both the primary and rollback errors, and
carry successful statement rowids through serverless batch decoding even
when a synthetic transaction step fails. Reject malformed serverless batch
responses instead of treating incomplete transaction steps as success.
The protocol reports complete per-statement information for a batch —
results, last insert rowid, error codes, and the execution statistics
rows_read, rows_written, and query_duration_ms — but batch() dropped
most of it. Extend the batch API compatibly, in the serverless driver
and in the embedded driver (@tursodatabase/database, whose
DatabasePromise is shared by the wasm and sync drivers), per the driver
API parity requirement:
- Each ResultSet also carries lastInsertRowid, plus rowsRead,
rowsWritten, and queryDurationMs on the serverless driver (the
embedded engine does not report those per statement). The
lastInsertRowid key is present only on entries whose statement
inserted, so `"lastInsertRowid" in resultSet` detects an insert.
- The serverless batch() uses a pipeline batch request instead of the
cursor endpoint, because the cursor stream does not carry the
statistics, and gates each statement on its predecessor succeeding,
so execution stops at the first failure instead of running the
remaining statements against a failed batch — the embedded driver's
sequential semantics.
- The thrown error carries batchIndex (the zero-based index of the
failing statement) and batchResults (one entry per statement: the
completed statement's ResultSet, or null for the failing and skipped
ones; empty when a bind value fails to encode client-side before
anything is sent), so callers can tell exactly which statements took
effect.
- The libsql-compat batch() returns the full libSQL ResultSet shape —
lastInsertRowid and toJSON() included, matching @libsql/client, whose
batch() returns the same ResultSet as execute() — and both of its
batch entry points preserve batchIndex and batchResults on the
LibsqlError they throw.
The JavaScript conformance contract covers the per-statement detail
fields. Also update the serverless integration tests that still
asserted positional access on expanded rows, removed in f52724d45.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Expanded rows grew hidden non-enumerable positional properties ("0",
"1", ...) in 4c0febfed ("Preserve JS row positional values") to work
around duplicate column names collapsing in object rows. That is a
Turso-only extension: neither better-sqlite3 nor libsql attaches
positional keys to expanded rows, so the conformance suite failed under
PROVIDER=better-sqlite3 and PROVIDER=libsql, and a result column
literally named "0" would collide with the synthetic property.
Remove the positional properties from the native binding's expanded row
mode and the serverless driver's createExpandedRow so expanded rows are
plain objects where duplicate names collapse, exactly like
better-sqlite3 and libsql. Positional access remains available through
raw mode, and the libsql-client compat surface keeps its genuine hybrid
rows built by Session.createRowObject.
The divergence went unnoticed because CI only ran the conformance suite
under PROVIDER=turso; the workflow now also runs it against
better-sqlite3 so drop-in incompatibilities fail in CI.
Tests: rewrote the positional-value tests to assert the collapsing
behavior plus raw-mode access, so they pass identically under the
turso, better-sqlite3, and libsql providers.
Closes#7907
Expanded rows grew hidden non-enumerable positional properties ("0",
"1", ...) in 4c0febfed ("Preserve JS row positional values") to work
around duplicate column names collapsing in object rows. That is a
Turso-only extension: neither better-sqlite3 nor libsql attaches
positional keys to expanded rows, so the conformance suite failed under
PROVIDER=better-sqlite3 and PROVIDER=libsql, and a result column
literally named "0" would collide with the synthetic property.
Remove the positional properties from the native binding's expanded row
mode and the serverless driver's createExpandedRow so expanded rows are
plain objects where duplicate names collapse, exactly like
better-sqlite3 and libsql. Positional access remains available through
raw mode, and the libsql-client compat surface keeps its genuine hybrid
rows built by Session.createRowObject.
The divergence went unnoticed because CI only ran the conformance suite
under PROVIDER=turso; the workflow now also runs it against
better-sqlite3 so drop-in incompatibilities fail in CI.
Tests: rewrote the positional-value tests to assert the collapsing
behavior plus raw-mode access, so they pass identically under the
turso, better-sqlite3, and libsql providers.
0.7 ships next week, and Turso now runs in production at multiple
organizations — the top-of-page "this software is in BETA, use caution
with production data" warning no longer reflects reality, and it's the
first thing every visitor reads.
## What changed
- **About**: the ⚠️ BETA warning blockquote is gone. In its place, a
one-line status note: Turso runs in production today, with a pointer to
the FAQ for where the project stands on the way to 1.0.
- **FAQ "Is Turso Database ready for production use?"**: now opens with
"Yes" and the production users, followed by the testing story (DST,
Antithesis). The honest caveats stay, but softened: not yet 1.0, some
features explicitly experimental, and backups recommended as "the same
discipline you would apply to any database" rather than as a data-loss
threat.
- **New FAQ "How compatible is Turso Database with SQLite?"**: we're not
at 100% yet, COMPAT.md tracks the details, the gap is closing quickly,
and full compatibility is a requirement for 1.0.
- **libSQL FAQ**: still flatly said "libSQL is production ready, Turso
Database is not", contradicting the rest of the page. Now: both run in
production; libSQL is more battle-tested, Turso Database is where
development effort is focused.
The goal is to neither scare nor oversell: no data-loss warning up top,
but the README still says clearly that we are pre-1.0 and that some
SQLite differences remain.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Reviewed-by: Mikaël Francoeur (@LeMikaelF)
Closes#7735
better-sqlite3 12.11.0 dropped its Node 20 (node-v115) prebuilt binaries
while still advertising engines.node "20.x", so `yarn install` on the
Node 20 CI runners falls back to compiling from source. That source build
is fragile across platforms: on macOS arm64 the bundled node-gyp@13 loads
an undici that calls webidl.util.markAsUncloneable (Node 22+ only) and
crashes, and on Windows older node-gyp can't detect the Visual Studio
version on the runner.
Pin better-sqlite3 to 12.9.0, the last release that publishes node-v115
prebuilds for every target platform (darwin-arm64/x64, win32-x64/arm64,
linux-x64/arm64, musl). With a prebuilt binary there is no source compile,
so node-gyp, Visual Studio, and undici never enter the picture.
Turso runs in production at multiple organizations, so the "this
software is in BETA, use caution with production data" warning no
longer reflects reality. It appeared in the main README, was
copy-pasted in 11 bindings READMEs (what users see on npm, PyPI, and
pkg.go.dev), and was printed by tursodb at every shell startup.
- README: remove the warning blockquote from About, leaving a one-line
status pointer. Rewrite the production-readiness FAQ to lead with
production use and the testing story, keeping the honest caveats in
softer form: not yet 1.0, some features experimental, keep backups
as with any database. Add a FAQ on SQLite compatibility (gap tracked
in COMPAT.md, closing quickly, required for 1.0), and fix the libSQL
FAQ, which still claimed Turso Database is not production ready.
- bindings READMEs: replace the warning with the same softened status
line, linking to the FAQ.
- cli: remove the startup banner line entirely, matching the SQLite
shell.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
I think JS has problems overall. But my guess here is that there is some
positional property that we were not adding.
Closes https://github.com/tursodatabase/turso/issues/7278
Vibed as Im not quite a JS script kiddie
Reviewed-by: Mikaël Francoeur (@LeMikaelF)
Reviewed-by: Pekka Enberg <penberg@iki.fi>
Closes#7285