mirror of
https://github.com/hanzoai/sqlbuilder.git
synced 2026-10-01 00:37:42 +00:00
Merge pull request #226 from shoriwe/fix/improve-error-context
fix #225: improve error-msg context for unsupported types during interpolation
This commit is contained in:
+3
-3
@@ -697,7 +697,7 @@ func encodeValue(buf []byte, arg interface{}, flavor Flavor) ([]byte, error) {
|
||||
}
|
||||
|
||||
if elem := primative.Type().Elem(); elem.Kind() != reflect.Uint8 {
|
||||
return nil, ErrInterpolateUnsupportedArgs
|
||||
return nil, fmt.Errorf("%w: only byte slices are supported", ErrInterpolateUnsupportedArgs)
|
||||
}
|
||||
|
||||
var data []byte
|
||||
@@ -750,11 +750,11 @@ func encodeValue(buf []byte, arg interface{}, flavor Flavor) ([]byte, error) {
|
||||
buf = append(buf, "')"...)
|
||||
|
||||
default:
|
||||
return nil, ErrInterpolateUnsupportedArgs
|
||||
return nil, fmt.Errorf("%w: unsupported flavor for hex number", ErrInterpolateUnsupportedArgs)
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, ErrInterpolateUnsupportedArgs
|
||||
return nil, fmt.Errorf("%w: %s", ErrInterpolateUnsupportedArgs, primative.Type().Name())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -385,7 +386,7 @@ func TestFlavorInterpolate(t *testing.T) {
|
||||
query, err := c.Flavor.Interpolate(c.SQL, c.Args)
|
||||
|
||||
a.Equal(query, c.Query)
|
||||
a.Assert(err == c.Err || err.Error() == c.Err.Error())
|
||||
a.Assert(errors.Is(err, c.Err) || strings.Contains(err.Error(), c.Err.Error()))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user