-
Notifications
You must be signed in to change notification settings - Fork 911
Closed
Labels
Description
CREATE TABLE users ( name TEXT NOT NULL );
-- name: ListUsers :many
SELECT *
FROM users
WHERE
($1 IS NULL OR name = $1);
Sometimes I do something like this to optionally query by a field. Since there's no type associated with $1 IS NULL
sqlc fails: nodes.ResTarget has nil name
.
I can fix this by re-ordering the WHERE clause:
SELECT *
FROM users
WHERE
(name = $1 OR $1 IS NULL);
But now the generated type is string
instead of sql.NullString
hulloitskai, aitva, ryda20, mlukasik-dev, rugginoso and 18 more