markphelps / optional

Optional is a library of optional Go types
https://godoc.org/github.com/markphelps/optional
MIT License
209 stars 19 forks source link

Optional for sql.Null* types #2

Open lunemec opened 6 years ago

lunemec commented 6 years ago

It would be awesome to have wrappers for sql.Null* types. It will be different from the generated primitive types though.

Example:

o := optional.NewNullInt64(sql.NullInt64{Valid: true, Int64: 55})

The question is, use it like in my example, or just implement sql.Scanner and sql.Valuer interfaces?

amjd commented 2 years ago

@markphelps What do you think about also implementing sql.Scanner and driver.Valuer for the generated optional types? This would help make this package compatible with most ORMs and drivers and one can use these types in both DTOs and database entities.