Skip to content

Commit

Permalink
Merge pull request #2793 from actiontech/2784
Browse files Browse the repository at this point in the history
fix: rule check column without comment not triggered
  • Loading branch information
taolx0 authored Dec 3, 2024
2 parents cb0747e + 28fc842 commit 4510a82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions sqle/driver/mysql/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,13 @@ ALTER TABLE exist_db.exist_tb_1 CHANGE COLUMN v2 v3 varchar(255) NOT NULL DEFAUL
`,
newTestResult().addResult(rulepkg.DDLCheckColumnWithoutComment),
)

runSingleRuleInspectCase(rule, t, "alter_table: column without comment(1)", DefaultMysqlInspect(),
`
ALTER TABLE exist_db.exist_tb_1 MODIFY COLUMN v3 varchar(500) NOT NULL DEFAULT "modified unit test";
`,
newTestResult().addResult(rulepkg.DDLCheckColumnWithoutComment),
)
}

func TestCheckIndexPrefix(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion sqle/driver/mysql/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ func checkColumnWithoutComment(input *RuleHandlerInput) error {
if stmt.Specs == nil {
return nil
}
for _, spec := range util.GetAlterTableSpecByTp(stmt.Specs, ast.AlterTableAddColumns, ast.AlterTableChangeColumn) {
for _, spec := range util.GetAlterTableSpecByTp(stmt.Specs, ast.AlterTableAddColumns, ast.AlterTableChangeColumn, ast.AlterTableModifyColumn) {
for _, col := range spec.NewColumns {
columnHasComment := false
for _, op := range col.Options {
Expand Down

0 comments on commit 4510a82

Please sign in to comment.