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

bug default语法审核 #406

Closed
ocpeng opened this issue Nov 20, 2021 · 4 comments
Closed

bug default语法审核 #406

ocpeng opened this issue Nov 20, 2021 · 4 comments
Labels
wontfix This will not be worked on

Comments

@ocpeng
Copy link

ocpeng commented Nov 20, 2021

描述
错误字段:update_time timestamp default null ON UPDATE CURRENT_TIMESTAMP comment "更新时间",
inception能审核出来,返回:"Invalid default value for column 'update_time'."
goinception返回:pass(审核不出来这种错误的语法)

goinception v1.2.4

@hanchuanchuan
Copy link
Owner

好的,已测试,下述两种写法在MySQL 5.7时第一种是没问题的。
但在MySQL v5.6时第一种写法也会报错,稍后会添加版本判断。

create table t1(id int primary key,c1 int,
update_time timestamp default null ON UPDATE CURRENT_TIMESTAMP comment "更新时间");

create table t2(id int primary key,c1 int,
update_time timestamp not null default null ON UPDATE CURRENT_TIMESTAMP comment "更新时间");

@ocpeng
Copy link
Author

ocpeng commented Nov 21, 2021

首先感谢。
我再描述一下,这种错误的写法(update_time timestamp default null ON UPDATE CURRENT_TIMESTAMP comment "更新时间",)
这种错误的写法v5.6,v5.7是都会报错的:返回:ERROR 1067 (42000): Invalid default value for 'update_time'
但是inception能够审核出来;而goinception不能审核出来。
我觉得是goinception没有加入这块功能判断么?请作者再次确认

@hanchuanchuan
Copy link
Owner

这个逻辑在goinception优化了,在MySQL v5.7是允许 update_time timestamp default null ON UPDATE CURRENT_TIMESTAMP这种写法的,而且也是合理并建议这么做的,更新时间首次写入时是应该为空的。
inception是基于MySQL 5.6源码改造的,并且主要管理5.6版本,所以是这个审核逻辑。
goinception更多的审核逻辑是v5.7版本的。

hanchuanchuan added a commit that referenced this issue Nov 21, 2021
update: 优化timestamp字段default null的审核逻辑 (#406)
@stale
Copy link

stale bot commented Dec 9, 2021

由于此问题没有最近的活动,因此已被自动标记为陈旧。如果没有进一步的活动,会作为不活跃issue关闭。感谢你对本项目的贡献。 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 9, 2021
@stale stale bot closed this as completed Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants