diff --git a/postgres/numeric.go b/postgres/numeric.go index 82c09a8..21e24cc 100644 --- a/postgres/numeric.go +++ b/postgres/numeric.go @@ -7,6 +7,9 @@ type Numeric struct { } func (n Numeric) GetFloat64() float64 { + if n.Status != pgtype.Present { + return 0 + } var balance float64 err := n.AssignTo(&balance) if err != nil { @@ -16,11 +19,17 @@ func (n Numeric) GetFloat64() float64 { } func (n Numeric) GetPositive() bool { + if n.Status != pgtype.Present { + return true + } float := n.GetFloat64() return float >= 0 } func (n Numeric) IsZero() bool { + if n.Status != pgtype.Present { + return true + } float := n.GetFloat64() return float == 0 }