Skip to content

Commit 2476262

Browse files
committed
feat: add IsZero() to sqlxx types
1 parent 8f55c13 commit 2476262

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sqlxx/types.go

+14
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,17 @@ func (ns *NullDuration) UnmarshalJSON(data []byte) error {
558558
ns.Valid = true
559559
return nil
560560
}
561+
562+
func (ns Duration) IsZero() bool { return time.Duration(ns) == 0 }
563+
func (m StringSliceJSONFormat) IsZero() bool { return len(m) == 0 }
564+
func (n StringSlicePipeDelimiter) IsZero() bool { return len(n) == 0 }
565+
func (ns NullBool) IsZero() bool { return !ns.Valid }
566+
func (ns FalsyNullBool) IsZero() bool { return !ns.Valid }
567+
func (ns NullString) IsZero() bool { return len(ns) == 0 }
568+
func (ns NullTime) IsZero() bool { return time.Time(ns).IsZero() }
569+
func (n MapStringInterface) IsZero() bool { return len(n) == 0 }
570+
func (m JSONArrayRawMessage) IsZero() bool { return len(m) == 0 }
571+
func (m JSONRawMessage) IsZero() bool { return len(m) == 0 }
572+
func (m NullJSONRawMessage) IsZero() bool { return len(m) == 0 }
573+
func (ns NullInt64) IsZero() bool { return !ns.Valid }
574+
func (ns NullDuration) IsZero() bool { return !ns.Valid }

0 commit comments

Comments
 (0)