Generate examples
These pages are snapshot fixtures from packages/sqlfu/test/generate/fixtures/. Each ##
heading you’ll find inside is a real test: the test harness parses the same markdown,
runs sqlfu generate against the declared inputs, and asserts the outputs match what’s
shown. That means every TypeScript file under an output block on these pages is
exactly what you’d find in your checkout after running the CLI. There is no drift.
Start here if you want to see what sqlfu generate produces for a given schema shape,
query style, or config knob, before you try it in your own project.
- Basics: Basic
sqlfu generatesnapshot fixtures. - Config: Fixtures for configuration knobs that shape what
sqlfu generateemits:sync,importExtension, tsconfig-driven.ts-import detection, nested query directories, and the runtime query catalog that drives the form UI. - Effect sql: Effect SQL fixtures:
generate.runtime: 'effect-v3' | 'effect-v4-unstable'emits functions that return Effect values and readSqlClient.SqlClientfrom the Effect environment instead of taking a sqlfuClient. - Errors: Error-case fixtures:
sqlfu generateshould refuse to run and throw a specific message. - Logical types: Logical-type fixtures for metadata-backed declared SQLite types.
- Native runtimes: Native runtime fixtures:
generate.runtimecan emit wrappers that call a user’s existing SQLite driver directly, so generated production query modules do not importsqlfu. - Query annotations: Query annotations let one SQL file declare multiple named queries.
- Query shapes: One test per query “shape” the generator recognizes: insert, insert-returning, update, delete, aggregate, user-defined function, and CTE.
- Result types: Result-type inference fixtures: how
sqlfu generatederives column types from the analyzed schema, aliases, view columns,is not nullnarrowing, expression aliases, andlimit 1single-row shape. - Validators: Validator-integration fixtures: zod, valibot, zod/mini, arktype.