diff --git a/errors.go b/errors.go index cc66567d..ce3a25c0 100644 --- a/errors.go +++ b/errors.go @@ -14,6 +14,8 @@ var ( ErrInvalidTransaction = errors.New("no valid transaction") // ErrCantStartTransaction can't start transaction when you are trying to start one with `Begin` ErrCantStartTransaction = errors.New("can't start transaction") + // ErrUnaddressable unaddressable value + ErrUnaddressable = errors.New("using unaddressable value") ) type errorsInterface interface { diff --git a/field.go b/field.go index bfaf00a3..11c410b0 100644 --- a/field.go +++ b/field.go @@ -21,7 +21,7 @@ func (field *Field) Set(value interface{}) (err error) { } if !field.Field.CanAddr() { - return errors.New("unaddressable value") + return ErrUnaddressable } reflectValue, ok := value.(reflect.Value) diff --git a/scope.go b/scope.go index 075fc948..425abc6d 100644 --- a/scope.go +++ b/scope.go @@ -846,10 +846,15 @@ func (scope *Scope) updatedAttrsWithValues(value interface{}) (results map[strin hasUpdate = true results[field.DBName] = value } else { - field.Set(value) + err := field.Set(value) if field.IsNormal { hasUpdate = true - results[field.DBName] = value + if err == ErrUnaddressable { + fmt.Println(err) + results[field.DBName] = value + } else { + results[field.DBName] = field.Field.Interface() + } } } }