Skip to content

Commit

Permalink
Fix package name in codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
Nan Huang committed Mar 21, 2022
1 parent 00d4c61 commit 25e5ec5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions internal/pkg/codegen/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 25e5ec5

Please sign in to comment.