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: (n *NullInt64) Scan identity #35228
I expected a
What version of Go are you using (
@gerardolima, the Scanner interface https://golang.org/pkg/database/sql/#Scanner scans and assigns values from a database driver. src is documented as the specific types that'll be most likely the values from the database which is why we only accept a few
and not every data type. Adding Scanning from NullInt64 could be nice but that's now over-serving the purpose which was to convert data from the wire from the database and into Go types; one can then argue we should also try reading from maps which then heavily loads the contract that the Scanner interface promised. With those reasons, I'd say let's not change what Scan promises, please follow its simple promise :)
hey, @odeke-em, thank you for the warm welcome!
I understand your reasoning and, me too, I do believe simple contracts is the way to go. Nevertheless, the implementation of such identity property would be really trivial and its absence, together with the lack of a way to get the value of NullX in a generic way, makes it very difficult to write A-B-A tests.
Maybe it would worth considering a (n *NullInt64) Compare, as an alternative? or should I consider this as too specific to my problem?