Open
Description
Version
1.17.2
What happened?
In my SQL query I'm selecting a value using a ->>
operator on my json column. I'm then casting the type and wrapping all with coalesce
with NULL as second arg. I'm expecting sqlc to infer the nullable type for me but instead I'm getting either the non nullable type or interface{}
.
Generated code:
func (q *Queries) GetObj(ctx context.Context) (time.Time, error) {
row := q.db.QueryRowContext(ctx, getObj)
var column time.Time
err := row.Scan(&column)
return column, err
}
Relevant log output
No response
Database schema
-- Example queries for sqlc
CREATE TABLE my_table (
some_obj json
);
SQL queries
-- name: GetObj :one
SELECT coalesce((some_obj->>my_date), NULL)::date as column FROM my_table;
Configuration
No response
Playground URL
https://play.sqlc.dev/p/679e757ece0f2e61056a32e3dac3c5aa1aeeef70c7211a7e5f1c28c0c77ed5c3
What operating system are you using?
No response
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go