Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated MySQL生成表结构体遇到关键字db部分保持原字段名定义 #1369

Merged
merged 1 commit into from
Dec 26, 2021

Conversation

qwxingzhe
Copy link
Contributor

现有user.sql

CREATE TABLE `user` (
  `id` int(8) NOT NULL AUTO_INCREMENT,
  `type` int(8) NOT NULL DEFAULT '0' COMMENT '类型',
  PRIMARY KEY (`id`),
  KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

在执行goctl model mysql ddl -src="./user.sql" -dir="." -c 时提示如下

[EscapeGolangKeyword]: go keyword is forbidden "type", converted into "tp"

生成的代码中User struct如下

	User struct {
		Id int64 `db:"id"`
		Tp int64 `db:"tp"` // 类型
	}

此代码需要将 db:"tp" 改为 db:"type" 方可使用,此即当前PR解决的问题。

@kevwan kevwan merged commit f5f2097 into zeromicro:master Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants