Development & Validation
Requires Node.js 20.0+ for the CLI and runtime; scripts, tests, example runs, and extension bundling use Bun. Scripts, tests, example runs, and extension bundling use Bun; server database tests need dedicated database services.
Test Scope
| Area | Coverage |
|---|---|
| Schema and types | Parsing, constraints, client generation, type inference |
| Queries and writes | SQL compilation, filters, projections, relation loading, nested writes |
| Transactions and lifecycle | Commit, rollback, timeouts, resource release, client shutdown |
| Adapters | Connection URLs, scalar conversion, key readback, error mapping |
| Migrations | Introspection, differences, history, risk checks, failure cleanup |
| Tooling | CLI and editor language features |
Install and Build
bun install
bun run build2
build compiles the ORM, regenerates the example and test clients, type-checks the repo and extension, builds docs, and packages the VS Code extension. Generated clients are git-ignored; bun run example without a database argument refreshes the example client. Focused checks:
bunx --no-install tsc -p tsconfig.types.json
bunx --no-install vitepress build docs2
Benchmarks and API Surface
Both report ns/op = (ms × 1e6) / samples (1 decimal). The first argument sets the run count; when comparing machines, take the median of several runs.
bun test/bench/bench.ts # decode hot paths, 40 runs by default
bun test/bench/bench.ts 5 # 5 runs
bun test/bench/bench-datetime.ts # 1,000,000 datetime values, 1 run by default
bun test/bench/bench-datetime.ts 3 # 3 runs2
3
4
bench.ts also covers bigintsAsText (with and without bigint values) and JSON validation via encodeJson. Reference thresholds — full row decode < 500 ns/row, bigintsAsText < 80 ns/row, ISO storedInstant < 45 ns/value — are measurement goals, not assertions; record real numbers and explain misses.
Tests guard the entrypoint symbol tables in the Client API against actual exports (@internal helpers excluded). Run after changing any export:
bun test test/unit/runtime.test.tsRelease
bun run release # tag the current package.json version
bun run release minor # patch | minor | major: bump, commit, then tag2
A dirty worktree is refused. A bump is committed as chore: release v<version> before tagging, and main plus the tag are pushed. The tag triggers CI build, tests, publishing, GitHub Release, and docs deployment on a single Bun version.
Regression Workflow
# Start compose services, wait for health checks, then run tests.
bun run test
# Forward a test path and additional Bun test options.
bun run test test/unit/schema.test.ts --timeout 10000
# Unit tests and offline suites only; matrix and server flows need a reachable server.
TEST_DATABASES=postgres bun test
# Require all listed services; unavailable targets fail the run.
TEST_DATABASES=postgres,mysql,mariadb bun test2
3
4
5
6
7
8
9
10
11
bun test discovers tests under test/ and extensions/test/; bun run test also starts examples/compose.yaml (requires Docker). Without TEST_DATABASES, the helper probes configured server databases and includes the reachable ones; an explicit list selects only those targets, and a listed but unreachable database fails the run.
| Database | Connection variables | Default test port |
|---|---|---|
| PostgreSQL | PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE | 5433 |
| MySQL | MYSQL_HOST, MYSQL_PORT, MYSQL_USER, MYSQL_PASSWORD | 3307 |
| MariaDB | MySQL variables with MARIADB_PORT | 3308 |
Integration tests create and remove isolated databases or schemas; use dedicated development services and accounts with the required permissions.
Documentation Standards
- State the contract and prerequisites before examples; distinguish supported behavior, database differences, and limitations; keep declarations, runtime behavior, and command options in their owning sections with links instead of repeats.
- Keep English and Chinese paths and contracts aligned; validate with
bunx --no-install vitepress build docs(type-check navigation changes), and record verification commands, database targets, and unverified scope when reporting.
Next Steps
- Documentation Map: topic locations
- Full Example: example schemas and execution