From 33fa14b761d71800d61ceab721e6f29e13a6d8bb Mon Sep 17 00:00:00 2001 From: David Cuadrado Date: Mon, 29 Jan 2024 16:00:22 -0500 Subject: [PATCH] Add a way to scan a reflect.Value It receives a reflect.Value as reference and sets the value into it. This change helps implementing ORMs. closes #520 --- internal/object/scan.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/internal/object/scan.go b/internal/object/scan.go index 0b733b14..4576e19d 100644 --- a/internal/object/scan.go +++ b/internal/object/scan.go @@ -28,9 +28,12 @@ func Scan(d types.Object, targets ...interface{}) error { target := targets[i] i++ - ref := reflect.ValueOf(target) - if !ref.IsValid() { - return &ErrUnsupportedType{target, fmt.Sprintf("Parameter %d is not valid", i)} + ref, ok := target.(reflect.Value) + if !ok { + ref = reflect.ValueOf(target) + if !ref.IsValid() { + return &ErrUnsupportedType{target, fmt.Sprintf("Parameter %d is not valid", i)} + } } return scanValue(v, ref)