aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/mattn/go-sqlite3/callback.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/mattn/go-sqlite3/callback.go')
-rw-r--r--vendor/github.com/mattn/go-sqlite3/callback.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/vendor/github.com/mattn/go-sqlite3/callback.go b/vendor/github.com/mattn/go-sqlite3/callback.go
index b020fe3..d305691 100644
--- a/vendor/github.com/mattn/go-sqlite3/callback.go
+++ b/vendor/github.com/mattn/go-sqlite3/callback.go
@@ -353,6 +353,20 @@ func callbackRetNil(ctx *C.sqlite3_context, v reflect.Value) error {
return nil
}
+func callbackRetGeneric(ctx *C.sqlite3_context, v reflect.Value) error {
+ if v.IsNil() {
+ C.sqlite3_result_null(ctx)
+ return nil
+ }
+
+ cb, err := callbackRet(v.Elem().Type())
+ if err != nil {
+ return err
+ }
+
+ return cb(ctx, v.Elem())
+}
+
func callbackRet(typ reflect.Type) (callbackRetConverter, error) {
switch typ.Kind() {
case reflect.Interface:
@@ -360,6 +374,11 @@ func callbackRet(typ reflect.Type) (callbackRetConverter, error) {
if typ.Implements(errorInterface) {
return callbackRetNil, nil
}
+
+ if typ.NumMethod() == 0 {
+ return callbackRetGeneric, nil
+ }
+
fallthrough
case reflect.Slice:
if typ.Elem().Kind() != reflect.Uint8 {