Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove QuerierConfig #100

Merged
merged 1 commit into from
Jan 2, 2024
Merged

Remove QuerierConfig #100

merged 1 commit into from
Jan 2, 2024

Conversation

jschaf
Copy link
Owner

@jschaf jschaf commented Jan 2, 2024

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

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
@jschaf jschaf merged commit c25070d into main Jan 2, 2024
2 checks passed
@jschaf jschaf deleted the joe/no-querier-config branch January 2, 2024 06:09
@kirk-anchor
Copy link

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

@kirk-anchor
Copy link

Never mind, it looks like shopspring-numeric won't work without the type override anyway

@jschaf
Copy link
Owner Author

jschaf commented Jan 3, 2024

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:

  • Make pgx v5 work
  • Figure out how to make arbitrary types work

@kirk-anchor
Copy link

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!

@kirk-anchor
Copy link

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

jschaf added a commit that referenced this pull request Jan 3, 2024
jschaf added a commit that referenced this pull request Jan 3, 2024
jschaf added a commit that referenced this pull request Jan 3, 2024
@kirk-anchor
Copy link

The problems I mentioned in this thread were because of composite types. I created an issue for it #102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants