修复sql语句没有COMMENT导致的panic问题 && 增加单元测试
This commit is contained in:
@ -64,12 +64,18 @@ func ParseCreateTableSql(sql string) (string, *BasicTableInfo, error) {
|
||||
structResult := "type " + basic.ModelStruct + " struct { \n"
|
||||
|
||||
for _, item := range r.TableSpec.Columns {
|
||||
comment := ""
|
||||
if item.Type.Comment == nil {
|
||||
comment = item.Name.String()
|
||||
} else {
|
||||
comment = string(item.Type.Comment.Val)
|
||||
}
|
||||
data := map[string]string{
|
||||
"{FIELD}": util.String.SnakeCaseToCamel(item.Name.String()),
|
||||
"{COLUMN}": item.Name.String(),
|
||||
"{JSON_TAG}": item.Name.String(),
|
||||
"{DEFAULT_VALUE}": "",
|
||||
"{COMMENT}": item.Name.String() + " " + string(item.Type.Comment.Val),
|
||||
"{COMMENT}": comment,
|
||||
"{TYPE}": sqlTypeMap[item.Type.Type],
|
||||
}
|
||||
if data["{FIELD}"] == "ID" {
|
||||
|
Reference in New Issue
Block a user