From 482c0bcd626ad4f722cb2cdb0afaa371b063cf01 Mon Sep 17 00:00:00 2001 From: Keyur Shah Date: Thu, 9 Jan 2025 12:08:54 -0800 Subject: [PATCH] Fix error due to value being returned as byte array by mysql. (#1495) --- internal/sqldb/model.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/sqldb/model.go b/internal/sqldb/model.go index ef4f869ac..0b85e9223 100644 --- a/internal/sqldb/model.go +++ b/internal/sqldb/model.go @@ -54,10 +54,17 @@ func (s *StringSlice) Scan(src interface{}) error { return nil } - val, ok := src.(string) - if !ok { - return fmt.Errorf("failed to decode []string: (%v)", src) + var val string + + switch v := src.(type) { + case []byte: + val = string(v) + case string: + val = v + default: + return fmt.Errorf("failed to decode []string: type = %T, value = %v", src, src) } + *s = strings.Split(val, ",") return nil }