Fixed Ignore Blank Fields On Create
Removed erroneous IsPrimaryKey check which caused fields that were not part of the Primary Key but were Blank to be inserted. (Particularly a problem because DeletedAt would be set to the zero value.)
This commit is contained in:
parent
836fb2c19d
commit
907f875972
@ -63,7 +63,7 @@ func createCallback(scope *Scope) {
|
||||
if field.IsBlank && field.HasDefaultValue {
|
||||
blankColumnsWithDefaultValue = append(blankColumnsWithDefaultValue, scope.Quote(field.DBName))
|
||||
scope.InstanceSet("gorm:blank_columns_with_default_value", blankColumnsWithDefaultValue)
|
||||
} else if !field.IsPrimaryKey || !field.IsBlank {
|
||||
} else if !field.IsBlank {
|
||||
columns = append(columns, scope.Quote(field.DBName))
|
||||
placeholders = append(placeholders, scope.AddToVars(field.Field.Interface()))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user