fix bug: crash when generate model with goctl. (#1777)

* fix bug: crash when generate model with goctl.

situation: column name with line.

CREATE TABLE test (
id int NOT NULL AUTO_INCREMENT,
zh-cn text CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '中文简体',
PRIMARY KEY (id) USING BTREE,
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

* group imports

group imports

* Use

go-zero/tools/goctl/util/string.go
 func SafeString(in string) string {
instead of ReplaceAll

Co-authored-by: 方航 <fanghang@tange.ai>
This commit is contained in:
方航
2022-04-11 10:11:40 +08:00
committed by GitHub
parent 6d9dfc08f9
commit fabea4c448
3 changed files with 3 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ func genInsert(table Table, withCache, postgreSql bool) (string, string, error)
expressionValues := make([]string, 0)
var count int
for _, field := range table.Fields {
camel := field.Name.ToCamel()
camel := util.SafeString(field.Name.ToCamel())
if camel == "CreateTime" || camel == "UpdateTime" {
continue
}