summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/dialect/sqlitedialect/scan.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/uptrace/bun/dialect/sqlitedialect/scan.go')
-rw-r--r--vendor/github.com/uptrace/bun/dialect/sqlitedialect/scan.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/github.com/uptrace/bun/dialect/sqlitedialect/scan.go b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/scan.go
new file mode 100644
index 000000000..44c50c2e9
--- /dev/null
+++ b/vendor/github.com/uptrace/bun/dialect/sqlitedialect/scan.go
@@ -0,0 +1,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())
+}