Handle nil in Numeric

This commit is contained in:
Jan Bader 2022-02-23 21:09:25 +00:00
parent bc65249c03
commit 34b6e450de

View File

@ -93,7 +93,7 @@ func (n Numeric) Add(other Numeric) Numeric {
} }
func (n Numeric) String() string { func (n Numeric) String() string {
if n.Int.Int64() == 0 { if n.Int == nil || n.Int.Int64() == 0 {
return "0" return "0"
} }
@ -130,7 +130,7 @@ func (n Numeric) String() string {
} }
func (n Numeric) MarshalJSON() ([]byte, error) { func (n Numeric) MarshalJSON() ([]byte, error) {
if n.Int.Int64() == 0 { if n.Int == nil || n.Int.Int64() == 0 {
return []byte("0"), nil return []byte("0"), nil
} }