Fix panic on assigning empty array to non-slice or array
See https://github.com/jackc/pgx/issues/881
This commit is contained in:
@@ -398,6 +398,12 @@ func (src *NumericArray) AssignTo(dst interface{}) error {
|
||||
value = value.Elem()
|
||||
}
|
||||
|
||||
switch value.Kind() {
|
||||
case reflect.Array, reflect.Slice:
|
||||
default:
|
||||
return errors.Errorf("cannot assign %T to %T", src, dst)
|
||||
}
|
||||
|
||||
if len(src.Elements) == 0 {
|
||||
if value.Kind() == reflect.Slice {
|
||||
value.Set(reflect.MakeSlice(value.Type(), 0, 0))
|
||||
|
||||
Reference in New Issue
Block a user