Closed jschaf closed 7 months ago
Since this removes support for --go-type 'numeric=github.com/shopspring/decimal.Decimal'
, is there a way to use github.com/jackc/pgtype/ext/shopspring-numeric
? The type is numeric.Numeric{}
in package numeric
but the directory is shopspring-numeric
Never mind, it looks like shopspring-numeric
won't work without the type override anyway
The --go-type should still work. The config was perhaps an unwise decision to provide a hook into how pgx marshals and unmarshals types. That logic should probably live where the connection is created.
pgx v5 also changed to use codecs. I'm not sure how that would've worked with this config approach. I still want to support arbitrary types. The plan is:
I tried to use --go-type
with https://github.com/jackc/pgtype/blob/master/ext/shopspring-numeric/decimal.go but it resulted in an error cannot convert {100 2} to Numeric
. I ended up using --go-type 'numeric=string'
, which works for me, and I was able to update to the latest commit. Looking forward to v5!
By the way, there is still a reference to NewQuerierConfig
in the template here https://github.com/jschaf/pggen/blob/main/internal/codegen/golang/query.gotemplate#L121
For v5, I think all uses of the github.com/jackc/pgtype
package need to be updated to the equivalents in github.com/jackc/pgx/v5/pgtype
. I made sure to use the v4 pgtype when I was trying the --go-type
The problems I mentioned in this thread were because of composite types. I created an issue for it https://github.com/jschaf/pggen/issues/102
It was a way to override the type encoders and decoders. It wasn't documented and makes it harder to upgrade to to pgx v5. Plus, we can't really change it in a way to that won't break existing users, so just remove it.e