Open mtsmfm opened 3 years ago
The decimal type is a bit weird. Because you have not null there, it expects you to have a value for it. Semi-intentional.
The decimal type is defined like this:
type Decimal struct {
*big.Decimal
}
so if the big.Decimal is nil it'll panic like this.
I don't know if it's fixable, but I'd accept a PR to do a check and return an error if it is.
This was fixed by #1044. And released in v4.8.4
The code above will now throw an error for violating the not-null constraint.
But this raises a new question:
Should the driver.Value()
of a new types.Decimal{}
be 0.0
? Currently, it would return nil
which the driver would report as NULL
.
We have explicit types.Decimal
and types.NullDecimal
and since we know that types.Decimal
is not meant to be NULL
should we prevent this by default?
PR: #1073
The following code fails with SIGSEGV
schema
https://gist.github.com/mtsmfm/738f16a88a0104d4f40692d68f30d68e
Is this intentional?