summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/schema/zerochecker.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-09-11 15:16:52 +0200
committerLibravatar GitHub <noreply@github.com>2023-09-11 15:16:52 +0200
commit7011f57b09fc03bde9d48fef191e904110c09c4b (patch)
tree1118192d6c8d49715d2293ee19c79e50b89de64e /vendor/github.com/uptrace/bun/schema/zerochecker.go
parent[chore]: Bump golang.org/x/net from 0.14.0 to 0.15.0 (#2193) (diff)
downloadgotosocial-7011f57b09fc03bde9d48fef191e904110c09c4b.tar.xz
[chore] bump bun v1.1.14 -> v1.1.15 (#2195)
Diffstat (limited to 'vendor/github.com/uptrace/bun/schema/zerochecker.go')
-rw-r--r--vendor/github.com/uptrace/bun/schema/zerochecker.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/uptrace/bun/schema/zerochecker.go b/vendor/github.com/uptrace/bun/schema/zerochecker.go
index f088b8c2c..f24e51d30 100644
--- a/vendor/github.com/uptrace/bun/schema/zerochecker.go
+++ b/vendor/github.com/uptrace/bun/schema/zerochecker.go
@@ -11,6 +11,45 @@ type isZeroer interface {
IsZero() bool
}
+func isZero(v interface{}) bool {
+ switch v := v.(type) {
+ case isZeroer:
+ return v.IsZero()
+ case string:
+ return v == ""
+ case []byte:
+ return v == nil
+ case int:
+ return v == 0
+ case int64:
+ return v == 0
+ case uint:
+ return v == 0
+ case uint64:
+ return v == 0
+ case float32:
+ return v == 0
+ case float64:
+ return v == 0
+ case int8:
+ return v == 0
+ case int16:
+ return v == 0
+ case int32:
+ return v == 0
+ case uint8:
+ return v == 0
+ case uint16:
+ return v == 0
+ case uint32:
+ return v == 0
+ default:
+ rv := reflect.ValueOf(v)
+ fn := zeroChecker(rv.Type())
+ return fn(rv)
+ }
+}
+
type IsZeroerFunc func(reflect.Value) bool
func zeroChecker(typ reflect.Type) IsZeroerFunc {