Skip to content

feat(ts): bind parameters in query - #1578

Merged
thekevinscott merged 4 commits into
mainfrom
bot/1575-ts-bind-params-1104
Nov 4, 2026
Merged

thekevinscott merged 4 commits into
mainfrom
bot/1575-ts-bind-params-1104

Conversation

@thekevinbot

@thekevinbot thekevinbot commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1575

TypeScript query(sql, params?) and queryOrdered(sql, params?) bind parameters through SQLite, matching the Python and Rust support from #1576. An array fills ?. A plain object fills :name / @name / $name, keyed without the prefix. Supported values: null, number (an integral value binds as INTEGER, any other as REAL), bigint within i64, boolean (0/1), string, and Buffer / Uint8Array. Any other value, undefined included, rejects with a TypeError; a bigint outside i64 rejects with a RangeError. Params that are neither an array nor a plain object reject with a TypeError. Count, name and style mismatches surface the core's DbError::Params message.

Red

Commit 276896b9 (tests only) went red in CI for the asserted reasons: https://github.com/thekevinscott/dirsql/actions/runs/41870669827

  • Binding tests: 13 of the new query-params tests failed because the params were never bound (the query has 2 parameter(s), but 0 value(s) were given, etc.).
  • Hermetic and unit tests: the wrapper did not forward params.
  • tsc: query / queryOrdered took 1 argument.

Parity

Restores parity. PARITY.md drops the TypeScript "Missing" entry for bind parameters.

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: N/A (only packages/ts changed)
  • TypeScript SDK e2e: pass (7 files, 19 tests, including the new tests/e2e/query-params.test.ts)
  • Rust core e2e (if applicable): N/A (core untouched)
  • packages/python/e2e-attestations/<branch>.json receipt written if packages/python changed: N/A
  • packages/ts/e2e-attestations/<branch>.json receipt written if packages/ts changed (just e2e-attest-ts)
  • Command(s) run: just e2e-attest-ts; just preflight --gate colocated-test --gate one-function-per-file --gate unit-lint --gate integration-lint --gate unit-coverage --gate packaging --gate e2e-verify (0 failing)
  • Result summary: all pass. Manual run against the built dist/index.js: query("... = :v", { v: "O'Brien'; DROP TABLE t; --" }) returns only a.json. queryOrdered("SELECT ? AS b, ? AS a, typeof(?) AS t", [1, 2.5, 3n]) returns columns b,a,t with t: 'integer'. [undefined] throws TypeError, "x" throws TypeError, [2n ** 64n] throws RangeError, and a count mismatch throws Error with the core message.

Changelog / Migrations

  • Changelog fragment added under packages/ts/changelog.d/ for each changed package
  • Migration fragment with the same slug added under packages/ts/migrations.d/ for each changed package (every subsection but Summary _None._ when nothing breaks)

The napi query and queryOrdered take no params yet, so every new test fails
on the placeholders left unbound or the params never forwarded.
An array fills ? placeholders and a plain object fills :name, @name and
$name placeholders, through SQLite's own binding, in query and
queryOrdered. Values that cannot bind reject with a TypeError, or a
RangeError for a bigint outside 64 bits.
@thekevinscott
thekevinscott marked this pull request as ready for review November 4, 2026 16:59
@thekevinscott
thekevinscott merged commit 74ce4a6 into main Nov 4, 2026
59 checks passed
@thekevinscott
thekevinscott deleted the bot/1575-ts-bind-params-1104 branch November 4, 2026 17:01
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.

Support bind parameters in DirSQL.query

2 participants