guregu / null

reasonable handling of nullable values
BSD 2-Clause "Simplified" License
1.84k stars 238 forks source link

Storing null values using this library in database #54

Closed padas2 closed 4 years ago

padas2 commented 4 years ago

Hello Greg (hope I got the name right :) )

First of all, great library for marshalling and unmarshalling Golang's SQL null datatypes. Really saved me a lot of time and effort.

However, I noticed that this library is missing one piece of functionality which is storing null values in database. I have gone through the library and could not find it anywhere. I had to implement this part in my own codebase. I would be happy to raise a Pull Request so that this functionality can be merged to master.

Please do let me know if I can go ahead with raising a pull request.

guregu commented 4 years ago

Hello, thanks!

Is this related to #55? All the types already implement Value() (by embedding the sql.NullXXX types) which does basically this. For example: https://golang.org/src/database/sql/sql.go?s=8507:8554#L324

So you can use the types in this package with database/sql and it should work.

padas2 commented 4 years ago

Thank, Greg. I will verify this info and get back to you.

padas2 commented 4 years ago

Hello Greg.

You were right. Using the existing types did work. Thanks for the info. I will close this issue and the pull request.