fix a bug that gorm:column not use.

This commit is contained in:
shine 2016-10-15 17:21:13 +08:00
parent 39165d4980
commit d0d746c6b5

View File

@ -533,8 +533,15 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
if value, ok := field.TagSettings["COLUMN"]; ok {
field.DBName = value
} else {
tag := field.Tag.Get("gorm")
if len(tag) > 0 && strings.HasPrefix(tag, "cloumn:") {
field.DBName = strings.Replace(tag, "cloumn:", "", -1)
} else {
field.DBName = ToDBName(fieldStruct.Name)
}
}
modelStruct.StructFields = append(modelStruct.StructFields, field)
}