Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions examples/check-only/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ query name is unknown to `tsc`, so every query carries a `// @ts-expect-error`;
`tsc` still runs over the rest of the file, and the describe-time `--check-queries`
pass is the real gate (`check:types` runs it before `tsc`).

Break a query — select a column that doesn't exist — and `check:queries` fails with
the real Postgres error, pointing at the file and line. `--check-queries` ignores
output freshness entirely; the sibling `--check-stale` (or `--check` for both) is
what guards a committed `queries.gen.ts` in the typed lane.
Run these commands from this directory; all write nothing:

| Command | Flags | Checks |
| --- | --- | --- |
| `bun run check:queries` | `--check-queries` | Queries plan against the schema; errors point at the file and line. |
| `bun run check:stale` | `--check-stale` | Generated types match the current queries and schema. |
| `bun run check:migration-order` | `--check-queries --check-migration-order '^\d+'` | Queries are valid and migration prefixes are present, unique, and the same width. |
| `bun run check` | `--check` | Query validity and generated-type freshness. |

`check:stale` and `check` fail here because `queries.gen.ts` is intentionally absent;
use them in the typed lane. `--check` doesn't include migration order. The
migration-order command adds `--check-queries` to avoid generating types.
3 changes: 3 additions & 0 deletions examples/check-only/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"private": true,
"type": "module",
"scripts": {
"check": "bun-sqlgen generate 'src/**/*.ts' --migrations src/db/migrations --check",
"check:queries": "bun-sqlgen generate 'src/**/*.ts' --migrations src/db/migrations --check-queries",
"check:stale": "bun-sqlgen generate 'src/**/*.ts' --migrations src/db/migrations --check-stale",
"check:migration-order": "bun-sqlgen generate 'src/**/*.ts' --migrations src/db/migrations --check-queries --check-migration-order '^\\d+'",
"check:types": "bun run check:queries && bun run --bun tsc"
},
"devDependencies": {
Expand Down
Loading