Skip to content

RowToStructByName doesn't play nice with nullable fields (oapi-codegen/nullable) #2214

Answered by jackc
artis3n asked this question in Q&A
Discussion options

You must be logged in to vote

Those types do not implement any database/sql or pgx interfaces so pgx has no way of knowing what to do with them. It's not just RowToStructByName, it wouldn't work with a normal Query / Scan either.

Presumably, you cannot modify that library so implementing the proper interfaces is not an option. However, pgx does have a way to support 3rd party types that cannot be modified. See https://github.com/jackc/pgx-shopspring-decimal for an example of how to support a 3rd party type. It can be a bit of work though. The adapter for shopspring/decimal is about 300 LOC. Start with the Register function if you want to explore the code.

Also, I doubt it can be done generically, so you would need to …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@artis3n
Comment options

Answer selected by artis3n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants