Skip to content

Commit

Permalink
[AB#1669514] simplify valuer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChronosMasterOfAllTime committed Sep 20, 2024
1 parent 97b609e commit 8f86d58
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,11 @@ func arrayToString(v driver.Value, tsmode snowflakeType, params map[string]*stri
} else if isSliceOfSlices(v) {
return bindingValue{}, errors.New("array of arrays is not supported")
} else if valuer, ok := v1.Interface().(driver.Valuer); ok { // check for driver.Valuer satisfaction and honor that first
value, err := valuer.Value()

if err != nil || value == nil {
return bindingValue{}, err
}

if v, ok := value.(string); ok {
return bindingValue{&v, "", nil}, nil
if value, err := valuer.Value(); err == nil && value != nil {
if v, ok := value.(string); ok {
return bindingValue{&v, "", nil}, nil
}
}

return bindingValue{}, nil
} else if stringer, ok := v1.Interface().(fmt.Stringer); ok { // alternate approach; check for stringer method. Guarantees it's String() and returns string
value := stringer.String()
return bindingValue{&value, "", nil}, nil
Expand Down

0 comments on commit 8f86d58

Please sign in to comment.