Skip to content

NULL values for embedded structs and row() with pgx.RowToStructByNameLax #1609

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

You must be logged in to vote

I do not know of a more elegant way, and I also do not think it is a bug.

The problem is that row(null, null) is being scanned into User. But the UserID and Name fields of User cannot be NULL.

Also, this is not specific to pgx.RowToStructByNameLax, the code in question is the general case composite to struct scanning system. You would have the same issue if you called Scan directly.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by taai
Comment options

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

jackc Nov 4, 2023
Maintainer

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