You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NULLIF(a, b) is NULL when a = b, but sqlc reports its column as NOT NULL. With a database, the generated field is string, and scanning a row where the two are equal fails.
For the query below, with analyzer.database: true and a database.uri, I get:
typeListNamesRowstruct {
IDint64Namestring
}
I expected Name pgtype.Text. With no database the field is Name bool: that type is the old problem of #133, and it is not nullable either.
It is the same on main (3ad8b20). I found no existing issue: #133 and #1154 are about the type.
NULLIF parses as an A_Expr with a comparison operator, and outputColumns gives every comparison NotNull: true. Checking for A_Expr_Kind_NULLIF there fixes it: Bockit@12f9b2a. I can open a pull request if that is wanted.
The analysis was done with AI help and checked by me.
Relevant log output
No response
Database schema
CREATETABLEdepots (id BIGSERIALPRIMARY KEY, name textNOT NULL);
SQL queries
-- name: ListNames :manySELECTd.id, nullif(d.name, 'unnamed') AS name FROM depots d;
Activity