blob: 44c50c2e9f66da1a46d99621bb6c3871bcccf611 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
package sqlitedialect
import (
"fmt"
"reflect"
"github.com/uptrace/bun/schema"
)
func scanner(typ reflect.Type) schema.ScannerFunc {
if typ.Kind() == reflect.Interface {
return scanInterface
}
return schema.Scanner(typ)
}
func scanInterface(dest reflect.Value, src interface{}) error {
if dest.IsNil() {
dest.Set(reflect.ValueOf(src))
return nil
}
dest = dest.Elem()
if fn := scanner(dest.Type()); fn != nil {
return fn(dest, src)
}
return fmt.Errorf("bun: can't scan %#v into %s", src, dest.Type())
}
|