forked from mirror/gorm
Don't save ignored fields into database
This commit is contained in:
parent
6f58f8a52c
commit
dc3b2476c4
|
@ -59,7 +59,7 @@ func createCallback(scope *Scope) {
|
|||
|
||||
for _, field := range scope.Fields() {
|
||||
if scope.changeableField(field) {
|
||||
if field.IsNormal {
|
||||
if field.IsNormal && !field.IsIgnored {
|
||||
if field.IsBlank && field.HasDefaultValue {
|
||||
blankColumnsWithDefaultValue = append(blankColumnsWithDefaultValue, scope.Quote(field.DBName))
|
||||
scope.InstanceSet("gorm:blank_columns_with_default_value", blankColumnsWithDefaultValue)
|
||||
|
|
2
scope.go
2
scope.go
|
@ -907,7 +907,7 @@ func (scope *Scope) updatedAttrsWithValues(value interface{}) (results map[strin
|
|||
results[field.DBName] = value
|
||||
} else {
|
||||
err := field.Set(value)
|
||||
if field.IsNormal {
|
||||
if field.IsNormal && !field.IsIgnored {
|
||||
hasUpdate = true
|
||||
if err == ErrUnaddressable {
|
||||
results[field.DBName] = value
|
||||
|
|
Loading…
Reference in New Issue