Skip to content

feat(ts): queryOrdered returns the projection order - #1182

Merged
thekevinscott merged 4 commits into
mainfrom
claude/1174-ts-projection-order
Sep 24, 2026
Merged

thekevinscott merged 4 commits into
mainfrom
claude/1174-ts-projection-order

Conversation

@thekevinbot

@thekevinbot thekevinbot commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1174

Adds db.queryOrdered(sql): Promise<QueryResult> to the TypeScript SDK, the counterpart of Rust's DirSQL::query_ordered from #1171.

interface QueryResult {
  columns: string[];                // SELECT-list order
  rows: Record<string, unknown>[];  // same rows query() returns
}

I added a separate accessor instead of promising key order on query()'s rows. A JS object can't hold that order: integer-like keys always enumerate first. query() is unchanged.

  • napi binding: a queryOrdered AsyncTask (it runs on the threadpool, like query) and an output-only QueryResult object. Unsafe integers still throw, as they do in query.
  • SDK wrapper: awaits ready and forwards the SQL. QueryResult is exported from the barrel.
  • PARITY.md: the TS cell is filled in. Python is still missing, tracked in Python SDK: no way to get a query's projection order #1173.
  • docs/reference/sdk.md: a queryOrdered section with TS and Rust tabs.

Red/green

Red commit 2c22bb6: the Integration tests (Node 24) job in run 35994554211 failed with TypeError: db.queryOrdered is not a function in the new hermetic test. The implementation followed in 42282d8.

Manual run

A Node script imports the built dist/index.js and uses SELECT name, age, 1 AS "2", 7 AS z:

query keys: [ '2', 'name', 'age', 'z' ]
queryOrdered: {"columns":["name","age","2","z"],"rows":[{"2":1,"age":30,"z":7,"name":"Alice"},{"2":1,"name":"Bob","z":7,"age":25}]}
empty: {"columns":["name"],"rows":[]}
error: SQLite error: no such column: nope in SELECT nope FROM users at offset 7

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: N/A
  • TypeScript SDK e2e: pass
  • Rust core e2e (if applicable): N/A (packages/rust/src untouched)
  • packages/python/e2e-attestations/<branch>.json receipt written if packages/python changed: N/A
  • packages/ts/e2e-attestations/<branch>.json receipt written (just e2e-attest-ts)
  • Command(s) run: just e2e-attest-ts, just preflight, cargo test / cargo clippy -D warnings on packages/ts/napi, full vitest run
  • Result summary: e2e 18/18 pass. Preflight: 0 failing pairs. Vitest: 255 tests pass.

Changelog / Migrations

  • Changelog fragment added under packages/ts/changelog.d/
  • Migration fragment added under packages/ts/migrations.d/ (additive; the gate requires one for any public-surface change)

@thekevinscott
thekevinscott merged commit a61c0fb into main Sep 24, 2026
48 checks passed
@thekevinscott
thekevinscott deleted the claude/1174-ts-projection-order branch September 24, 2026 21: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.

TypeScript SDK: no way to get a query's projection order

2 participants