Skip to content

Column receives "" when updating with zero values using pgtype.Text #1727

Answered by jackc
Nikola-Milovic asked this question in Q&A
Discussion options

You must be logged in to vote

When using pgtype.Text with the UPDATE SQL statement, if no value is provided for a specific field, it is updated with an empty string "". I expected that if no value is provided and IsValid is false, the field would be ignored and not updated, rather than being overwritten with an empty string.

Valid == false means the field is the SQL NULL. It does not control whether the field is updated or not.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Nikola-Milovic
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