Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
database/sql: convert NULL to empty string #2814
It would be nice if the sql package could scan NULL into a string variable, giving an empty string, instead of requiring a NullString variable to handle NULLs. Users could still use NullString if they care about the distinction. See https://groups.google.com/forum/#!topic/golang-nuts/jNdrSeq97hY
I think we've decided not to do this after thinking about it for a while. It would be inconsistent with the rest of the value converters which have a policy of never losing data. Just like they won't convert the string "257" into a uint8, we shouldn't collapse "" and NULL together. Also, if we did it for strings, people would want it for ints too, and NULL vs 0 seems potentially more serious than NULL vs "". I'd rather see people modify their SQL to collapse them there explicitly if they want, or write NullString explicitly if they want to get one out. I think that being explicit about types feels more Go-like.
Status changed to WorkingAsIntended.