Skip to content

Commit

Permalink
Fix error due to value being returned as byte array by mysql. (#1495)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurva authored Jan 9, 2025
1 parent 946e091 commit 482c0bc
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/sqldb/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 482c0bc

Please sign in to comment.