2
0

Fix panic on assigning empty array to non-slice or array

See https://github.com/jackc/pgx/issues/881
This commit is contained in:
Jack Christensen
2020-11-27 11:56:21 -06:00
parent 740b3a5115
commit 00d516f5c4
25 changed files with 156 additions and 0 deletions
+6
View File
@@ -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))