From bbb9b6ba736ed596e7c1371dd97a9c77da1cc59f Mon Sep 17 00:00:00 2001 From: Jason Moiron Date: Tue, 27 Feb 2018 23:40:31 -0500 Subject: [PATCH] adjust PropertyMap test to drivers that may return string now instead of []byte as the base type for Scanners; a test-only change that has all tests passing again --- sqlx_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sqlx_test.go b/sqlx_test.go index 9502c13e..1c97f2f8 100644 --- a/sqlx_test.go +++ b/sqlx_test.go @@ -1387,13 +1387,17 @@ func (p PropertyMap) Value() (driver.Value, error) { func (p PropertyMap) Scan(src interface{}) error { v := reflect.ValueOf(src) - if !v.IsValid() || v.IsNil() { + if !v.IsValid() || v.CanAddr() && v.IsNil() { return nil } - if data, ok := src.([]byte); ok { - return json.Unmarshal(data, &p) + switch ts := src.(type) { + case []byte: + return json.Unmarshal(ts, &p) + case string: + return json.Unmarshal([]byte(ts), &p) + default: + return fmt.Errorf("Could not not decode type %T -> %T", src, p) } - return fmt.Errorf("Could not not decode type %T -> %T", src, p) } func TestEmbeddedMaps(t *testing.T) {