Open knpwrs opened 3 months ago
It seems like this might be related to not specifying a schema.sql
file. Does that sound right?
I got everything generating correctly and now I understand the purpose of that code in the linked issue. Any custom types need to be registered with pgx or else there will be a runtime failure when pgx tries to read the value into the struct.
I did this as such:
func getDbConn(ctx context.Context) *pgx.Conn {
conn, err := pgx.Connect(ctx, os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatalln(err)
}
dataTypeNames := []string{
"upload_variant",
"_upload_variant",
}
for _, typeName := range dataTypeNames {
dataType, err := conn.LoadType(ctx, typeName)
if err != nil {
log.Fatalln(err)
}
conn.TypeMap().RegisterType(dataType)
}
return conn
}
Version
1.26.0
What happened?
When I select an enum array column in Postgres (pgx) with sqlc the generated type for that column is
[]interface{}
. For some reason this doesn't reproduce in the playground.I came across this issue but I am new to Go and I'm not quite sure what to do with this code, or if it is even relevant to the issue I am seeing: https://github.com/sqlc-dev/sqlc/issues/2116#issuecomment-1493299852
This is the output:
Relevant log output
No response
Database schema
SQL queries
Configuration
Playground URL
https://play.sqlc.dev/p/e60a8ebfe202c5a91bdaaee9b3aef12b085f188ceec8e62b4503c59c6f1d553c
What operating system are you using?
Linux, macOS
What database engines are you using?
PostgreSQL
What type of code are you generating?
Go