From 34b6e450de8a3edf9a8b80136101aaa4741b9409 Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Wed, 23 Feb 2022 21:09:25 +0000 Subject: [PATCH] Handle nil in Numeric --- postgres/numeric.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/postgres/numeric.go b/postgres/numeric.go index cf8dea4..9483e87 100644 --- a/postgres/numeric.go +++ b/postgres/numeric.go @@ -93,7 +93,7 @@ func (n Numeric) Add(other Numeric) Numeric { } func (n Numeric) String() string { - if n.Int.Int64() == 0 { + if n.Int == nil || n.Int.Int64() == 0 { return "0" } @@ -130,7 +130,7 @@ func (n Numeric) String() string { } func (n Numeric) MarshalJSON() ([]byte, error) { - if n.Int.Int64() == 0 { + if n.Int == nil || n.Int.Int64() == 0 { return []byte("0"), nil }