Skip to content
pre-alpha. The TypeScript API may still shift. The SQL won't.

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 generate snapshot fixtures.
  • Config: Fixtures for configuration knobs that shape what sqlfu generate emits: 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 read SqlClient.SqlClient from the Effect environment instead of taking a sqlfu Client.
  • Errors: Error-case fixtures: sqlfu generate should 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.runtime can emit wrappers that call a user’s existing SQLite driver directly, so generated production query modules do not import sqlfu.
  • 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 generate derives column types from the analyzed schema, aliases, view columns, is not null narrowing, expression aliases, and limit 1 single-row shape.
  • Validators: Validator-integration fixtures: zod, valibot, zod/mini, arktype.