mirror of https://github.com/go-gorm/gorm.git
Do not set CreatedAt if blank during Save (#2207)
This commit is contained in:
parent
e2cfd6be3b
commit
a6382da485
|
@ -75,7 +75,7 @@ func updateCallback(scope *Scope) {
|
||||||
} else {
|
} else {
|
||||||
for _, field := range scope.Fields() {
|
for _, field := range scope.Fields() {
|
||||||
if scope.changeableField(field) {
|
if scope.changeableField(field) {
|
||||||
if !field.IsPrimaryKey && field.IsNormal {
|
if !field.IsPrimaryKey && field.IsNormal && (field.Name != "CreatedAt" || !field.IsBlank) {
|
||||||
if !field.IsForeignKey || !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())))
|
sqls = append(sqls, fmt.Sprintf("%v = %v", scope.Quote(field.DBName), scope.AddToVars(field.Field.Interface())))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue