From ea1bce3771e1a022f8e8f1b62fd9d88e52f5743c Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Sun, 23 May 2021 11:21:56 +0800 Subject: [PATCH] Only check struct value can address or not --- statement.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/statement.go b/statement.go index a87fd212..85bf1726 100644 --- a/statement.go +++ b/statement.go @@ -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() { case reflect.Slice, reflect.Array: 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) } case reflect.Struct: + if !stmt.ReflectValue.CanAddr() { + stmt.AddError(ErrInvalidValue) + return + } + field.Set(stmt.ReflectValue, value) } } else {