forked from mirror/gorm
Include ignored columns in Fields(), it could be used as cache field
This commit is contained in:
parent
5d0d2a8e98
commit
6c1ca7adb8
11
scope.go
11
scope.go
|
@ -414,11 +414,12 @@ func (scope *Scope) Fields(noRelations ...bool) map[string]*Field {
|
|||
if field.IsPrimaryKey {
|
||||
hasPrimaryKey = true
|
||||
}
|
||||
if field.IsIgnored {
|
||||
continue
|
||||
}
|
||||
if _, ok := fields[field.DBName]; ok {
|
||||
panic(fmt.Sprintf("Duplicated column name for %v (%v)\n", scope.typeName(), fileWithLineNum()))
|
||||
if value, ok := fields[field.DBName]; ok {
|
||||
if value.IsIgnored {
|
||||
fields[field.DBName] = field
|
||||
} else if !value.IsIgnored {
|
||||
panic(fmt.Sprintf("Duplicated column name for %v (%v)\n", scope.typeName(), fileWithLineNum()))
|
||||
}
|
||||
} else {
|
||||
fields[field.DBName] = field
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue