Params for nullable columns accept null, even though = NULL never matches a row in SQL:
// schema: email: string | null
Params<DB, 'select id from users where email = $1'> // [string | null]
db.query('select id from users where email = $1', null); // compiles, matches nothing
Join-induced nullability leaks the same way:
Params<DB, 'select u.id from users u left join posts p on u.id = p.user_id where p.views = $1'>
// [number | null]
The LEFT JOIN case shows the mechanism plainly: the | null belongs to the result side (a missing match makes the column null in the output), not to the value you compare against. like $1 behaves the same.
Root cause: ParamType resolves through ResolveColumnLoose (src/params.ts:213-223), which reuses result-column resolution verbatim, | null included. Stripping null from comparison-position params would turn the silent no-match query into a compile error, which is the kind of mistake the library is built to catch.
Params for nullable columns accept
null, even though= NULLnever matches a row in SQL:Join-induced nullability leaks the same way:
The LEFT JOIN case shows the mechanism plainly: the
| nullbelongs to the result side (a missing match makes the column null in the output), not to the value you compare against.like $1behaves the same.Root cause:
ParamTyperesolves throughResolveColumnLoose(src/params.ts:213-223), which reuses result-column resolution verbatim,| nullincluded. Stripping null from comparison-position params would turn the silent no-match query into a compile error, which is the kind of mistake the library is built to catch.