Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: let the logical of table-naming and column-naimg be the same (#1240)
rebeliceaacb3cd2f437
diff --git a/plugin/advisor/mysql/advisor_naming_table.go b/plugin/advisor/mysql/advisor_naming_table.goindex 7533dbc18b..97e32c8286 100644--- a/plugin/advisor/mysql/advisor_naming_table.go+++ b/plugin/advisor/mysql/advisor_naming_table.go@@ -86,23 +86,16 @@ func (v *namingTableConventionChecker) Enter(in ast.Node) (ast.Node, bool) {}}- code := common.Ok-for _, tableName := range tableNames {if !v.format.MatchString(tableName) {- code = common.NamingTableConventionMismatch- break+ v.adviceList = append(v.adviceList, advisor.Advice{+ Status: v.level,+ Code: common.NamingTableConventionMismatch,+ Title: "Mismatch table naming convention",+ Content: fmt.Sprintf("`%s` mismatches table naming convention, naming format should be %q", tableName, v.format),+ })}}-- if code != common.Ok {- v.adviceList = append(v.adviceList, advisor.Advice{- Status: v.level,- Code: code,- Title: "Mismatch table naming convention",- Content: fmt.Sprintf("%q mismatches table naming convention", in.Text()),- })- }return in, false}diff --git a/plugin/advisor/mysql/advisor_naming_table_test.go b/plugin/advisor/mysql/advisor_naming_table_test.goindex b40cd2fe14..ee7027adbe 100644--- a/plugin/advisor/mysql/advisor_naming_table_test.go+++ b/plugin/advisor/mysql/advisor_naming_table_test.go@@ -19,7 +19,7 @@ func TestNamingTableConvention(t *testing.T) {Status: advisor.Error,Code: common.NamingTableConventionMismatch,Title: "Mismatch table naming convention",- Content: "\"CREATE TABLE techBook(id int, name varchar(255))\" mismatches table naming convention",+ Content: "`techBook` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)?$\"",},},},@@ -41,7 +41,7 @@ func TestNamingTableConvention(t *testing.T) {Status: advisor.Error,Code: common.NamingTableConventionMismatch,Title: "Mismatch table naming convention",- Content: "\"ALTER TABLE techBook RENAME TO TechBook\" mismatches table naming convention",+ Content: "`TechBook` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)?$\"",},},},@@ -63,7 +63,24 @@ func TestNamingTableConvention(t *testing.T) {Status: advisor.Error,Code: common.NamingTableConventionMismatch,Title: "Mismatch table naming convention",- Content: "\"RENAME TABLE techBook TO tech_book, literaryBook TO LiteraryBook\" mismatches table naming convention",+ Content: "`LiteraryBook` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)?$\"",+ },+ },+ },+ {+ statement: "RENAME TABLE techBook TO TechBook, literaryBook TO LiteraryBook",+ want: []advisor.Advice{+ {+ Status: advisor.Error,+ Code: common.NamingTableConventionMismatch,+ Title: "Mismatch table naming convention",+ Content: "`TechBook` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)?$\"",+ },+ {+ Status: advisor.Error,+ Code: common.NamingTableConventionMismatch,+ Title: "Mismatch table naming convention",+ Content: "`LiteraryBook` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)?$\"",},},},