duplicated column with no tag assign IsIgnored struct

This commit is contained in:
edv1n 2019-10-21 23:25:53 +02:00 committed by GitHub
parent afef5813d8
commit f4ece8aae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -621,13 +621,20 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
// look for field which has tag COLUMN assigned, if found any, set other fields which has the same DBName to IsIgnored = true
for _, v := range modelStruct.StructFields {
if column, ok := v.TagSettingsGet("COLUMN"); ok {
for _, field := range modelStruct.StructFields {
for k, field := range modelStruct.StructFields {
if field == v {
continue
}
if field.DBName == column {
field.IsIgnored = true
field.IsNormal = false
ignoredField := &StructField{
Struct: field.Struct,
Name: field.Name,
Names: field.Names,
Tag: field.Tag,
TagSettings: field.TagSettings,
IsIgnored: true,
}
modelStruct.StructFields[k] = ignoredField
}
}
}