8 Commits

Author SHA1 Message Date
Pekka Enberg
f52724d450 bindings/js, serverless/js: collapse duplicate column names in expanded rows
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.
2026-07-20 20:11:59 +03:00
Pekka Enberg
3a1d853d15 conformance/javascript: cover big integer round-trip with safe integers
Add a conformance test to the JavaScript async and sync suites that stores
i64::MAX, i64::MIN, and 2^53+1 and reads them back with safe integers
enabled, asserting exact BigInt round-trip. Verified against the turso and
better-sqlite3 providers.
2026-06-22 09:38:48 +03:00
Pekka Enberg
45e80cfe26 Return per-statement results from batch()
Make the JavaScript batch() return an array of ResultSet, one per input
statement, matching the libSQL client contract. Each ResultSet carries
that statement's columns, columnTypes, rows (with both positional and
named access), rowsAffected, and a BigInt lastInsertRowid.

Previously the native Database.batch() returned an aggregate
{ rowsAffected, lastInsertRowid } and discarded rows, while the
libSQL-compat client.batch() ignored statement args and collapsed all
statements into a single result. This reworks every layer:

- Native Database.batch() reads each statement's columns, collects rows
  in raw mode, and builds one ResultSet per statement.
- session.batch() requests rows (want_rows) and returns one raw result
  per statement, preserving the atomic Hrana condition chain.
- Connection.batch() shapes each result into a libSQL ResultSet.
- compat client.batch() binds args and runs the batch atomically.

Add conformance tests for both the native Database.batch() and the
libSQL-compat client.batch().
2026-06-18 09:09:38 +03:00
Pedro Muniz
7715979bd0 Merge 'Preserve JS row positional values' from Pedro Muniz
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
2026-06-08 16:22:28 -03:00
pedrocarlo
4c0febfed2 Preserve JS row positional values 2026-06-02 18:58:41 -03:00
Pekka Enberg
e5ddef05ed javascript: Fix Database.inTransaction property
Fix the inTransaction property to probe the database connection whether
it is in a transaction or not.
2026-06-01 18:36:54 +03:00
Pekka Enberg
6bdbacdd45 testing/conformance: Allow non-native errors in query timeout tests
ava's t.throws()/t.throwsAsync() validate the thrown value with
util.types.isNativeError(), which only returns true for objects whose
internal [[ErrorData]] slot was set by the Error constructor. libsql's
SqliteError uses the legacy `Error.call(this)` subclassing pattern (same
as better-sqlite3, the canonical Node SQLite API it mirrors), so its
instances pass `instanceof Error` but fail isNativeError. Pass
`{ any: true }` to bypass that check rather than diverging from the
canonical libsql/better-sqlite3 error shape.
2026-04-28 11:33:39 +03:00
Pekka Enberg
9ee0386373 Move JavaScript conformance tests 2026-04-28 10:42:58 +03:00