guregu / null

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

uint64 support #71

Closed Fabio1988 closed 1 year ago

Fabio1988 commented 1 year ago

Hey guys,

is it on purpose that this module can not support uint64 (bigint unsigned)?

casting uint64 to int64 will cause a loss of the last bit. And therefore I would have wrong results in DB

type Thing struct {
  Id string `db:"id"`
  number null.Int `db:"name"`

Database has the schema:

CREATE TABLE `thing` (
`id` varchar(25) NOT NULL,
`number` bigint unsigned DEFAULT NULL
)

Implemtation of null.IntFrom

Is it sqlx not supporting it? How can I work around that?! :) related to: https://github.com/go-sql-driver/mysql/issues/715 ?

guregu commented 1 year ago

Hey. Yes, it's related to the issue you linked. Basically, Go's sql package does not guarantee support of uint64. See: here.

There is a fork of this package here that has a lot more types. I'd suggest checking that out if you need them: https://github.com/volatiletech/null

Fabio1988 commented 1 year ago

Thank you :)