Open MisterSweety opened 9 months ago
@EasyEesteren I believe implementing such an override may be risky. Others may choose to use uint64
and this may cause out of range errors in PostgreSQL as it does not natively support unsigned integers at the moment.
@EasyEesteren I believe implementing such an override may be risky. Others may choose to use
uint64
and this may cause out of range errors in PostgreSQL as it does not natively support unsigned integers at the moment.
It might be risky, but what sqlc 1.25 is doing now is really confusing. If the override is not going to be applied a warning would be very helpful at the very least.
I have a similar problem as @EasyEesteren with this configuration:
version: "2"
sql:
- schema: "server/db/schema.sql"
queries: "server/db/queries.sql"
engine: "postgresql"
gen:
go:
package: "db"
out: "server/db"
overrides:
- db_type: "bigint"
go_type: "int"
This is generating bigints as int64 in my models.go, but technically speaking this should be valid right?
Is there any progress?
I have the simillar issue with this types:
- db_type: pg_catalog.numeric
go_type: int
But Im getting this:
type AddChatMessageParams struct {
ChatID *int64
UserID pgtype.Numeric
Text string
Timestamp pgtype.Timestamp
}
Sorry that folks are running into issues with overrides. They sadly can be tricky to use (they weren't designed super well). I cant' help you debug these issues without seeing the database schema and associated query, as that determines which types the overrides see.
Can you reproduce on the playground and post the results here?
I have same problem (1.27.0). Override working for bigserial, but not for bigint ` version: "2" sql:
with query
SELECT id
FROM table
where table.id = ANY($1::bigint[]);
func (q *Queries) Get(ctx context.Context, dollar_1 []int64) (uint64, error)`
Version
Other
What happened?
I am writing a service which can receive uint32 values that it has to persist in a postgres database. I am using sqlc to generate the go code to interact with the database. My database design uses 'bigint' for these id columns. By default the generated code expects the type int64 for the bigint id fields but I want to override this to be uint32 as that is more inline with reality. However, adjusting my sqlc.yaml file to include this override does not have the desired effect as the generated code still expects int64
Relevant log output
No response
Database schema
No response
SQL queries
No response
Configuration