A library declares its columns as package-level values. Col[T] is where the type comes from: Email is an sqlb.Expr[string] and CreatedAt an sqlb.Expr[time.Time].
1Declare the table once
2A correct query builds
3Wrong type in a comparison
4Wrong scan target
5Joining mismatched columns
6A Postgres clause on SQLite
7Engine expressions: caught at Build
8A real database checks execution
←→ step · space play
All steps as text
Declare the table once. A library declares its columns as package-level values. Col[T] is where the type comes from: Email is an sqlb.Expr[string] and CreatedAt an sqlb.Expr[time.Time].
A correct query builds. Comparing the string column ID with a string, and scanning Email into a string, type checks. go build succeeds and Build renders the SQL.
Wrong type in a comparison. Comparing the string column Email with the number 42 does not compile. The compiler stops the build before any SQL exists.
Wrong scan target. Binding the string column Email to an *int does not compile either, so a scan can never write into the wrong kind of variable.
Joining mismatched columns. EqExpr compares two columns at their Go types. Joining the string ID to the time.Time CreatedAt does not compile.
A Postgres clause on SQLite. Engine clauses are typed to their dialect. pg.ForUpdate() on a SQLite statement does not compile.
Engine expressions: caught at Build. This is the honest limit of the type system. A pgvector expression under the SQLite dialect compiles, but Build returns ErrUnsupportedDialect naming the construct, in your process, before anything reaches a database.
A real database checks execution. Rendering SQL is not the same as running it. Every driver runs a shared conformance suite, and the pgx driver executes every pg construct (593 cases) against Postgres 17.
The compiler messages in the diagram are the real output of go build for those statements, built against the sqlb source, with only the file:line:col prefix removed.
The README’s own list of what does not compile includes a string column bound to an *int, a time column compared with a string, a vector distance over a text column, and a sum over a non-numeric column. examples/typecheck in the repository holds deliberately wrong statements like these behind a build tag, and the project’s gate fails if that file ever compiles.