fix to update callback for gorm tests

This commit is contained in:
Phillip Shipley 2018-07-16 15:58:20 -04:00
parent 77a1fc6994
commit 088b993df9

View File

@ -76,7 +76,7 @@ func updateCallback(scope *Scope) {
for _, field := range scope.Fields() {
if scope.changeableField(field) {
if !field.IsPrimaryKey && field.IsNormal {
if !field.IsBlank || !field.HasDefaultValue {
if !field.IsForeignKey || !field.IsBlank || !field.HasDefaultValue {
sqls = append(sqls, fmt.Sprintf("%v = %v", scope.Quote(field.DBName), scope.AddToVars(field.Field.Interface())))
}
} else if relationship := field.Relationship; relationship != nil && relationship.Kind == "belongs_to" {