Skip to content

Error scanning into a var of type []sql.NullString #2255

Answered by ousloob
taylorsilva asked this question in Q&A
Discussion options

You must be logged in to vote

@taylorsilva
The issue arises because pgx does not support scanning directly into slices of sql.NullString (or other database/sql nullable types). However, pgx does support scanning into Go slices of native types like []string.

To work around this, you can use []string instead (if you don't need to differentiate NULL values).
Use pgtype.TextArray from pgx's pgtype package if you need more control over NULL values.

Hope this helps! 🙂

Replies: 1 comment 1 reply

Comment options

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

Answer selected by taylorsilva
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