-
Notifications
You must be signed in to change notification settings - Fork 978
Open
Labels
Description
Version
1.11.0
What happened?
The types in a query are not overwritten. I want to overwrite the "real" type in the following query with a a sql.NullFloat64 in the go code.
The P75 is parsed into a go float32 field wich explodes if the value is NULL
type GetUrlLCPPercentilesRow struct {
P75 float32
One interface{}
}
func (q *Queries) GetUrlLCPPercentiles(ctx context.Context, arg GetUrlLCPPercentilesParams) (GetUrlLCPPercentilesRow, error) {
row := q.db.QueryRowContext(ctx, getUrlLCPPercentiles, arg.Auth0id, arg.StartDate, arg.EndDate)
var i GetUrlLCPPercentilesRow
err := row.Scan(&i.P75, &i.One)
return i, err
}
Now I tried to use an overwrite to get rid of this problem (see config below), but sadly the type of P75 is not adapted to sql.NullFloat64 as expected.
Relevant log output
No response
Database schema
No response
SQL queries
-- name: GetUrlLCPPercentiles :one
SELECT percentile_disc(0.75) WITHIN GROUP(ORDER BY lcp)::real P75, 1 as one
FROM event
WHERE lcp IS NOT NULL AND
auth0id = $1 AND
date(created_at) >= date(sqlc.arg(start_date)::date) AND date(created_at) <= date(sqlc.arg(end_date)::date);Configuration
"version": "1"
"packages":
- path: "internal/db/event"
schema: "schema/"
queries: "internal/db/event/sql/"
engine: "postgresql"
- path: "internal/db/account"
schema: "schema/"
queries: "internal/db/account/sql/"
engine: "postgresql"
overrides:
- db_type: "real"
go_type: "database/sql.NullFloat64"
nullable: true
- db_type: "real"
go_type: "database/sql.NullFloat64"
nullable: falsePlayground URL
No response
What operating system are you using?
Linux
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go