Include ignored columns in Fields(), it could be used as cache field

This commit is contained in:
Jinzhu 2014-10-14 00:06:41 +08:00
parent 5d0d2a8e98
commit 6c1ca7adb8
1 changed files with 6 additions and 5 deletions

View File

@ -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 {
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
}