From 51ac582a7abdaaee94bc0785c334ac5e00a6ee33 Mon Sep 17 00:00:00 2001 From: edv1n <54180289+edv1n@users.noreply.github.com> Date: Thu, 17 Oct 2019 17:22:15 +0200 Subject: [PATCH] add code to ignore duplicated column --- model_struct.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/model_struct.go b/model_struct.go index 5234b287..828fd30f 100644 --- a/model_struct.go +++ b/model_struct.go @@ -617,6 +617,20 @@ func (scope *Scope) GetModelStruct() *ModelStruct { modelStruct.StructFields = append(modelStruct.StructFields, field) } } + + // 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 { + if field == v { + continue + } + if field.DBName == column { + field.IsIgnored = true + } + } + } + } if len(modelStruct.PrimaryFields) == 0 { if field := getForeignField("id", modelStruct.StructFields); field != nil {