summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/model.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-01-22 12:26:47 +0100
committerLibravatar GitHub <noreply@github.com>2023-01-22 12:26:47 +0100
commit0ceacd7b1d0b03e3da1d552aa0bbbe7037e57e90 (patch)
tree106bd6f80fe5466522b37b5778ebc7c4fd6ab728 /vendor/github.com/uptrace/bun/model.go
parent[chore] Add name to instance field for autosuggestion (#1359) (diff)
downloadgotosocial-0ceacd7b1d0b03e3da1d552aa0bbbe7037e57e90.tar.xz
[chore] bump db dependencies (#1366)
Diffstat (limited to 'vendor/github.com/uptrace/bun/model.go')
-rw-r--r--vendor/github.com/uptrace/bun/model.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/vendor/github.com/uptrace/bun/model.go b/vendor/github.com/uptrace/bun/model.go
index 88ec48992..6ad4d8efe 100644
--- a/vendor/github.com/uptrace/bun/model.go
+++ b/vendor/github.com/uptrace/bun/model.go
@@ -13,7 +13,10 @@ import (
var errNilModel = errors.New("bun: Model(nil)")
-var timeType = reflect.TypeOf((*time.Time)(nil)).Elem()
+var (
+ timeType = reflect.TypeOf((*time.Time)(nil)).Elem()
+ bytesType = reflect.TypeOf((*[]byte)(nil)).Elem()
+)
type Model = schema.Model
@@ -102,19 +105,22 @@ func _newModel(db *DB, dest interface{}, scan bool) (Model, error) {
}
v = v.Elem()
+ typ := v.Type()
+
+ switch typ {
+ case timeType, bytesType:
+ return newScanModel(db, []interface{}{dest}), nil
+ }
switch v.Kind() {
case reflect.Map:
- typ := v.Type()
if err := validMap(typ); err != nil {
return nil, err
}
mapPtr := v.Addr().Interface().(*map[string]interface{})
return newMapModel(db, mapPtr), nil
case reflect.Struct:
- if v.Type() != timeType {
- return newStructTableModelValue(db, dest, v), nil
- }
+ return newStructTableModelValue(db, dest, v), nil
case reflect.Slice:
switch elemType := sliceElemType(v); elemType.Kind() {
case reflect.Struct: