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() {
|
for _, field := range scope.Fields() {
|
||||||
if scope.changeableField(field) {
|
if scope.changeableField(field) {
|
||||||
if field.IsNormal {
|
if field.IsNormal && !field.IsIgnored {
|
||||||
if field.IsBlank && field.HasDefaultValue {
|
if field.IsBlank && field.HasDefaultValue {
|
||||||
blankColumnsWithDefaultValue = append(blankColumnsWithDefaultValue, scope.Quote(field.DBName))
|
blankColumnsWithDefaultValue = append(blankColumnsWithDefaultValue, scope.Quote(field.DBName))
|
||||||
scope.InstanceSet("gorm:blank_columns_with_default_value", blankColumnsWithDefaultValue)
|
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
|
results[field.DBName] = value
|
||||||
} else {
|
} else {
|
||||||
err := field.Set(value)
|
err := field.Set(value)
|
||||||
if field.IsNormal {
|
if field.IsNormal && !field.IsIgnored {
|
||||||
hasUpdate = true
|
hasUpdate = true
|
||||||
if err == ErrUnaddressable {
|
if err == ErrUnaddressable {
|
||||||
results[field.DBName] = value
|
results[field.DBName] = value
|
||||||
|
|
Loading…
Reference in New Issue