Skip to content

docs: fix sqlite query/getRow examples (the <T> form alone doesn't compile)#515

Merged
cs01 merged 1 commit intomainfrom
sqlite-docs-fix
Apr 15, 2026
Merged

docs: fix sqlite query/getRow examples (the <T> form alone doesn't compile)#515
cs01 merged 1 commit intomainfrom
sqlite-docs-fix

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Apr 15, 2026

Summary

The current sqlite docs examples don't compile. They show:

const users = sqlite.query<User>(db, "SELECT ...");
const user = sqlite.getRow<User>(db, "SELECT ...");

Both forms fail at the compile step — the bare <T> type argument is silently ignored by codegen, so the result type is unknown and users.length / user.name produce errors.

What actually works (and what the existing fixtures use) is the variable type annotation:

const users: User[] = sqlite.query(db, "SELECT ...");
const user: User | null = sqlite.getRow(db, "SELECT ...");

The annotation drives the typed reload of the rows; the <T> is parser noise.

What changed

  • docs/stdlib/sqlite.md — every sqlite.query<T>(...) and sqlite.getRow<T>(...) example now uses the variable-annotation form. Headings updated accordingly. getRow examples now show the honest User | null return type.

Test plan

  • Verified all 6 example forms by hand: type-arg-only fails, annotation-only passes, annotation + type-arg passes (the <T> is ignored), no annotation + no type-arg fails.
  • Existing fixtures tests/fixtures/builtins/sqlite-query.ts and sqlite-get-row.ts continue to pass — they already used the annotation pattern.

@github-actions
Copy link
Copy Markdown
Contributor

Benchmark Results (Linux x86-64)

Benchmark C ChadScript Go Node Place
Binary Trees 1.274s 1.325s 2.963s 1.343s 🥈
Cold Start 0.5ms 0.6ms 1.0ms 25.2ms 🥈
Fibonacci 0.725s 0.724s 1.430s 2.839s 🥇
File I/O 0.080s 0.073s 0.073s 0.218s 🥇
JSON Parse/Stringify 0.003s 0.004s 0.017s 0.014s 🥈
Matrix Multiply 0.372s 0.398s 0.424s 0.431s 🥈
Monte Carlo Pi 0.400s 0.381s 0.405s 1.473s 🥇
N-Body Simulation 1.450s 1.848s 1.946s 2.340s 🥈
Quicksort 0.170s 0.216s 0.183s 0.248s 🥉
SQLite 0.310s 0.333s 0.415s 🥈
Sieve of Eratosthenes 0.026s 0.039s 0.034s 0.054s 🥉
String Manipulation 0.008s 0.017s 0.016s 0.035s 🥉

CLI Tool Benchmarks

Benchmark ChadScript grep node xxd Place
Hex Dump 0.409s 0.947s 0.070s 🥈
Recursive Grep 0.011s 0.007s 0.093s 🥈

@cs01 cs01 merged commit 539d87e into main Apr 15, 2026
13 checks passed
@cs01 cs01 deleted the sqlite-docs-fix branch April 15, 2026 05:58
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.

1 participant