forked from mirror/gorm
Don't panic when using nil pointer, close #4168
This commit is contained in:
parent
675de6fc16
commit
14b9bd163c
|
@ -96,7 +96,7 @@ func (p *processor) Execute(db *DB) {
|
||||||
if stmt.Dest != nil {
|
if stmt.Dest != nil {
|
||||||
stmt.ReflectValue = reflect.ValueOf(stmt.Dest)
|
stmt.ReflectValue = reflect.ValueOf(stmt.Dest)
|
||||||
for stmt.ReflectValue.Kind() == reflect.Ptr {
|
for stmt.ReflectValue.Kind() == reflect.Ptr {
|
||||||
if stmt.ReflectValue.IsNil() {
|
if stmt.ReflectValue.IsNil() && stmt.ReflectValue.CanAddr() {
|
||||||
stmt.ReflectValue.Set(reflect.New(stmt.ReflectValue.Type().Elem()))
|
stmt.ReflectValue.Set(reflect.New(stmt.ReflectValue.Type().Elem()))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue