From b341a78912fd83b89b4c8478a997d0457aa18e36 Mon Sep 17 00:00:00 2001 From: Richard Lindhout Date: Fri, 24 Dec 2021 16:08:32 +0100 Subject: [PATCH] fix bug --- convert_plugin.go | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/convert_plugin.go b/convert_plugin.go index 719b5a4..e9ff80c 100755 --- a/convert_plugin.go +++ b/convert_plugin.go @@ -530,25 +530,26 @@ func enhanceModelsWithFields(enums []*Enum, schema *ast.Schema, cfg *config.Conf enum := findEnum(enums, shortType) field := &Field{ - Name: name, - JSONName: jsonName, - Type: shortType, - TypeWithoutPointer: strings.Replace(strings.TrimPrefix(shortType, "*"), ".", "Dot", -1), - BoilerField: boilerField, - IsNumberID: isNumberID, - IsPrimaryID: isPrimaryID, - IsPrimaryNumberID: isPrimaryNumberID, - IsPrimaryStringID: isPrimaryStringID, - IsRelation: boilerField.IsRelation, - IsRelationAndNotForeignKey: boilerField.IsRelation && !boilerField.IsForeignKey, - IsObject: isObject, - IsOr: strings.EqualFold(name, "or"), - IsAnd: strings.EqualFold(name, "and"), - IsPlural: IsPlural(name), - PluralName: Plural(name), - OriginalType: typ, - Description: field.Description, - Enum: enum, + Name: name, + JSONName: jsonName, + Type: shortType, + TypeWithoutPointer: strings.Replace(strings.TrimPrefix(shortType, "*"), ".", "Dot", -1), + BoilerField: boilerField, + IsNumberID: isNumberID, + IsPrimaryID: isPrimaryID, + IsPrimaryNumberID: isPrimaryNumberID, + IsPrimaryStringID: isPrimaryStringID, + IsRelation: boilerField.IsRelation, + IsRelationAndNotForeignKey: boilerField.IsRelation && + !strings.HasSuffix(strings.ToLower(name), "id"), + IsObject: isObject, + IsOr: strings.EqualFold(name, "or"), + IsAnd: strings.EqualFold(name, "and"), + IsPlural: IsPlural(name), + PluralName: Plural(name), + OriginalType: typ, + Description: field.Description, + Enum: enum, } field.ConvertConfig = getConvertConfig(enums, m, field) m.Fields = append(m.Fields, field)