Allow overwrite ignored field's permission, close #3829

This commit is contained in:
Jinzhu 2020-12-06 11:06:52 +08:00
parent 61d3a4d6ea
commit f655041908
2 changed files with 2 additions and 2 deletions

View File

@ -161,7 +161,7 @@ func Parse(dest interface{}, cacheStore *sync.Map, namer Namer) (*Schema, error)
} }
} }
if _, ok := schema.FieldsByName[field.Name]; !ok { if of, ok := schema.FieldsByName[field.Name]; !ok || of.TagSettings["-"] == "-" {
schema.FieldsByName[field.Name] = field schema.FieldsByName[field.Name] = field
} }

View File

@ -576,7 +576,7 @@ func (stmt *Statement) SelectAndOmitColumns(requireCreate, requireUpdate bool) (
} }
if stmt.Schema != nil { if stmt.Schema != nil {
for _, field := range stmt.Schema.Fields { for _, field := range stmt.Schema.FieldsByName {
name := field.DBName name := field.DBName
if name == "" { if name == "" {
name = field.Name name = field.Name