From 25e5ec5db74a3256811074977f90f569e982f7ce Mon Sep 17 00:00:00 2001 From: Nan Huang Date: Mon, 21 Mar 2022 21:36:18 +0000 Subject: [PATCH] Fix package name in codegen --- internal/pkg/codegen/model.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/pkg/codegen/model.go b/internal/pkg/codegen/model.go index d2aa6a1..b6857ed 100644 --- a/internal/pkg/codegen/model.go +++ b/internal/pkg/codegen/model.go @@ -137,7 +137,11 @@ func FromDbTableModel(tableModel dbmodel.DbTableModel, tableDef config.TableDef) } typeTokens := strings.Split(codegenCol.ColumnGoType, ".") if len(typeTokens) > 1 { - importPackages[typeTokens[0]] = true + packageName := typeTokens[0] + if packageName[0:1] == "*" { + packageName = packageName[1:] + } + importPackages[packageName] = true } codegenCol.ColumnFieldName = strcase.ToCamel(codegenCol.ColumnLowerName) codegenCol.ColumnVariableName = strcase.ToLowerCamel(codegenCol.ColumnLowerName) @@ -262,7 +266,11 @@ func FromDbQueryModel(queryModel dbmodel.DbQueryModel, queryDef config.QueryDef) } typeTokens := strings.Split(codegenCol.ColumnGoType, ".") if len(typeTokens) > 1 { - importPackages[typeTokens[0]] = true + packageName := typeTokens[0] + if packageName[0:1] == "*" { + packageName = packageName[1:] + } + importPackages[packageName] = true } codegenModel.QueryColumnList = append(codegenModel.QueryColumnList, &codegenCol) }