Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: add baseLine for each statement (#8919)
zll600b581f1e58241
diff --git a/backend/plugin/advisor/mysqlwip/advisor_naming_table.go b/backend/plugin/advisor/mysqlwip/advisor_naming_table.goindex 569d99a464..9a20eae2f6 100644--- a/backend/plugin/advisor/mysqlwip/advisor_naming_table.go+++ b/backend/plugin/advisor/mysqlwip/advisor_naming_table.go@@ -51,6 +51,7 @@ func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]adv}for _, stmt := range list {+ checker.baseLine = stmt.BaseLineantlr.ParseTreeWalkerDefault.Walk(checker, stmt.Tree)}return checker.generateAdvice()@@ -59,6 +60,7 @@ func (*NamingTableConventionAdvisor) Check(ctx advisor.Context, _ string) ([]advtype namingTableConventionChecker struct {*mysql.BaseMySQLParserListener+ baseLine intadviceList []advisor.Advicelevel advisor.Statustitle string@@ -123,6 +125,7 @@ func (checker *namingTableConventionChecker) EnterRenameTableStatement(ctx *mysq}func (checker *namingTableConventionChecker) handleTableName(tableName string, lineNumber int) {+ lineNumber += checker.baseLineif !checker.format.MatchString(tableName) {checker.adviceList = append(checker.adviceList, advisor.Advice{Status: checker.level,diff --git a/backend/plugin/advisor/mysqlwip/test/naming_table.yaml b/backend/plugin/advisor/mysqlwip/test/naming_table.yamlindex 2336e69666..046cd2c40a 100644--- a/backend/plugin/advisor/mysqlwip/test/naming_table.yaml+++ b/backend/plugin/advisor/mysqlwip/test/naming_table.yaml@@ -22,15 +22,19 @@content: "`cjnubexocfhqoogdmihudyahmmghviqkzvpixnwvxtxumvuannpwdcbtsgwrvzpde` mismatches table naming convention, its length should be within 64 characters"line: 1details: ""-- statement: ALTER TABLE tech_book RENAME TO TechBook;+- statement: |+ CREATE TABLE tech_book(a INT);+ ALTER TABLE tech_book RENAME TO TechBook;want:- status: WARNcode: 301title: naming.tablecontent: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1+ line: 2details: ""-- statement: ALTER TABLE tech_book RENAME TO tech_book_copy;+- statement: |+ CREATE TABLE tech_book(a INT);+ ALTER TABLE tech_book RENAME TO tech_book_copy;want:- status: SUCCESScode: 0@@ -38,32 +42,36 @@content: ""line: 0details: ""-- statement: RENAME TABLE tech_book TO tech_book_copy, tech_book_copy TO LiteraryBook;+- statement: |+ CREATE TABLE tech_book (a INT);+ RENAME TABLE tech_book TO tech_book_copy, tech_book_copy TO LiteraryBook;want:- status: WARNcode: 301title: naming.tablecontent: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 1+ line: 2details: ""- statement: |CREATE TABLE literary_book(a int);+ CREATE TABLE tech_book(a int);RENAME TABLE tech_book TO TechBook, literary_book TO LiteraryBook;want:- status: WARNcode: 301title: naming.tablecontent: '`LiteraryBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2+ line: 3details: ""- status: WARNcode: 301title: naming.tablecontent: '`TechBook` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- line: 2+ line: 3details: ""- statement: |CREATE TABLE literary_book(a int);+ CREATE TABLE teck_book(a int);RENAME TABLE tech_book TO tech_book_copy, literary_book TO literary_book_copy;want:- status: SUCCESS