diff --git a/main.go b/main.go index d580c5a5..a56f282f 100644 --- a/main.go +++ b/main.go @@ -418,7 +418,7 @@ func (s *DB) HasTable(value interface{}) bool { func (s *DB) AutoMigrate(values ...interface{}) *DB { db := s.clone() for _, value := range values { - db = db.NewScope(value).NeedPtr().autoMigrate().db + db = db.NewScope(value).autoMigrate().db } return db } diff --git a/scope.go b/scope.go index 0abfa132..b0c2432c 100644 --- a/scope.go +++ b/scope.go @@ -35,16 +35,6 @@ func (scope *Scope) IndirectValue() reflect.Value { return *scope.indirectValue } -func (scope *Scope) NeedPtr() *Scope { - reflectKind := reflect.ValueOf(scope.Value).Kind() - if !((reflectKind == reflect.Invalid) || (reflectKind == reflect.Ptr)) { - err := fmt.Errorf("%v %v\n", fileWithLineNum(), "using unaddressable value") - scope.Err(err) - fmt.Printf(err.Error()) - } - return scope -} - // New create a new Scope without search information func (scope *Scope) New(value interface{}) *Scope { return &Scope{db: scope.NewDB(), Search: &search{}, Value: value} diff --git a/utils_private.go b/utils_private.go index c4f0e963..5c17eda5 100644 --- a/utils_private.go +++ b/utils_private.go @@ -63,8 +63,7 @@ func convertInterfaceToMap(values interface{}) map[string]interface{} { attrs[ToDBName(key.Interface().(string))] = reflectValue.MapIndex(key).Interface() } default: - scope := Scope{Value: values} - for _, field := range scope.Fields() { + for _, field := range (&Scope{Value: values}).Fields() { if !field.IsBlank && !field.IsIgnored { attrs[field.DBName] = field.Field.Interface() }