From 39267af9ad681daba2bf060ef12d14a67c17ddcb Mon Sep 17 00:00:00 2001 From: Tue Date: Tue, 4 Oct 2022 15:56:34 +0700 Subject: [PATCH] fix code --- set.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/set.go b/set.go index ec44177..3636693 100644 --- a/set.go +++ b/set.go @@ -19,21 +19,27 @@ func SetInt(val int) null.Int { } } -func SetBool(val bool) null.Bool { +func SetBool(val bool) (res null.Bool) { return null.Bool{ Bool: val, Valid: true, } } -func SetTime(val time.Time) null.Time { +func SetTime(val time.Time) (res null.Time) { + if val.IsZero() { + return + } return null.Time{ Time: val, Valid: true, } } -func SetJSON(val []byte) null.JSON { +func SetJSON(val []byte) (res null.JSON) { + if val == nil { + return + } return null.JSON{ JSON: val, Valid: true,