处理 string 和 int, converting NULL to string is unsupported
This commit is contained in:
@@ -167,8 +167,15 @@ func SafeSetFieldByIndex(v reflect.Value, fieldIndex []int, src interface{}) (re
|
||||
return v
|
||||
case 1:
|
||||
f := v.FieldByIndex(fieldIndex)
|
||||
srcVal := reflect.ValueOf(src)
|
||||
f.Set(reflect.Indirect(srcVal))
|
||||
srcVal := reflect.ValueOf(src).Elem()
|
||||
// 处理 converting NULL to string is unsupported
|
||||
// 前面将 string 和 int 类型转为了 *string 和 *int
|
||||
// 这里做还原
|
||||
if f.Type().ConvertibleTo(srcVal.Type().Elem()) {
|
||||
f.Set(srcVal.Elem())
|
||||
} else {
|
||||
f.Set(srcVal)
|
||||
}
|
||||
default:
|
||||
f := v.Field(fieldIndex[0])
|
||||
switch f.Kind() {
|
||||
|
||||
Reference in New Issue
Block a user