Open
Description
Version
1.15.0
What happened?
In the playground example I supplied, you can see that I have used both sqlc.arg
and sqlc.narg
when casting to TEXT[]
, but the generated code does not contain sql.NullString
for the second argument as I expected.
Input:
-- name: batchUpsert :exec
INSERT INTO authors (id, name, bio)
VALUES (
unnest(sqlc.arg(ids)::BIGINT[]),
unnest(sqlc.arg(names)::TEXT[]),
unnest(sqlc.narg(bios)::TEXT[])
) ON CONFLICT (id) DO UPDATE SET
name = EXCLUDED.name,
bio = EXCLUDED.bio;
Output:
type batchUpsertParams struct {
Ids []int64
Names []string
Bios []string
}
Expected:
type batchUpsertParams struct {
Ids []int64
Names []string
Bios []sql.NullString
}
If I take away the array part of the cast, so ::TEXT
instead of ::TEXT[]
, it seems to work as expected, so I assume that this is a bug, and not intentional.
If there are any other way to have a dynamic batching system someone could recommend, I will give that a try, but so far, this is what I have.
Thanks
Relevant log output
No response
Database schema
No response
SQL queries
No response
Configuration
No response
Playground URL
https://play.sqlc.dev/p/b0fb935d443804af71bba41ac58800b54db5992209579ec08d27e00b6a61a111
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go