Skip to content

Commit

Permalink
update: 优化timestamp字段default null的审核逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
hanchuanchuan committed Nov 21, 2021
1 parent 00a92d0 commit 4055599
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions session/session_inception.go
Expand Up @@ -4197,6 +4197,14 @@ func (s *session) mysqlCheckField(t *TableInfo, field *ast.ColumnDef, alterTable
// if !mysql.HasNoDefaultValueFlag(field.Tp.Flag) {
if !hasDefaultValue {
s.appendErrorNo(ER_TIMESTAMP_DEFAULT, field.Name.Name.O)
} else if hasDefaultValue {
// v5.6在使用default null后即使指定on update仍会报错
// https://github.com/hanchuanchuan/goInception/issues/406
if _, ok := defaultExpr.(*ast.ValueExpr); ok &&
defaultValue.IsNull() && !notNullFlag && s.dbVersion < 50700 {
//有默认值,且为NULL,且有NOT NULL约束,如(not null default null)
s.appendErrorNo(ER_INVALID_DEFAULT, field.Name.Name.O)
}
}
}

Expand Down

0 comments on commit 4055599

Please sign in to comment.