good morning!!!!

Skip to content
Snippets Groups Projects
Commit a30f6a47 authored by José Carlos's avatar José Carlos Committed by GitHub
Browse files

Merge pull request #255 from upper/hotfix/add-has-is-zero-interface

Add hasIsZero() interface to prevent  runtime errors
parents 2efbb71c 203f322a
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,10 @@ import ( ...@@ -15,6 +15,10 @@ import (
"upper.io/db.v2/lib/reflectx" "upper.io/db.v2/lib/reflectx"
) )
type hasIsZero interface {
IsZero() bool
}
type hasArguments interface { type hasArguments interface {
Arguments() []interface{} Arguments() []interface{}
} }
...@@ -215,7 +219,11 @@ func Map(item interface{}) ([]string, []interface{}, error) { ...@@ -215,7 +219,11 @@ func Map(item interface{}) ([]string, []interface{}, error) {
} }
if _, ok := fi.Options["omitempty"]; ok { if _, ok := fi.Options["omitempty"]; ok {
if value == fi.Zero.Interface() { if t, ok := fld.Interface().(hasIsZero); ok {
if t.IsZero() {
continue
}
} else if value == fi.Zero.Interface() {
continue continue
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment