Only check struct value can address or not

This commit is contained in:
Jinzhu 2021-05-23 11:21:56 +08:00
parent 79f427d862
commit ea1bce3771
1 changed files with 5 additions and 5 deletions

View File

@ -540,11 +540,6 @@ func (stmt *Statement) SetColumn(name string, value interface{}, fromCallbacks .
} }
} }
if !stmt.ReflectValue.CanAddr() {
stmt.AddError(ErrInvalidValue)
return
}
switch stmt.ReflectValue.Kind() { switch stmt.ReflectValue.Kind() {
case reflect.Slice, reflect.Array: case reflect.Slice, reflect.Array:
if len(fromCallbacks) > 0 { if len(fromCallbacks) > 0 {
@ -555,6 +550,11 @@ func (stmt *Statement) SetColumn(name string, value interface{}, fromCallbacks .
field.Set(stmt.ReflectValue.Index(stmt.CurDestIndex), value) field.Set(stmt.ReflectValue.Index(stmt.CurDestIndex), value)
} }
case reflect.Struct: case reflect.Struct:
if !stmt.ReflectValue.CanAddr() {
stmt.AddError(ErrInvalidValue)
return
}
field.Set(stmt.ReflectValue, value) field.Set(stmt.ReflectValue, value)
} }
} else { } else {