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: write string to yaml (#9354)
zll600b57034cd31ff
diff --git a/backend/tests/sql_review_test.go b/backend/tests/sql_review_test.goindex 33bb0a63c3..a369bb357c 100644--- a/backend/tests/sql_review_test.go+++ b/backend/tests/sql_review_test.go@@ -5,7 +5,6 @@ package testsimport ("context""database/sql"- "encoding/json""fmt""io""os"@@ -153,9 +152,7 @@ func TestSQLReviewForPostgreSQL(t *testing.T) {}if record {- byteValue, err := yaml.Marshal(tests)- a.NoError(err)- err = os.WriteFile(filepath, byteValue, 0644)+ err := writeTestData(filepath, tests)a.NoError(err)}@@ -319,9 +316,7 @@ func TestSQLReviewForMySQL(t *testing.T) {}if record {- byteValue, err := yaml.Marshal(tests)- a.NoError(err)- err = os.WriteFile(filepath, byteValue, 0644)+ err := writeTestData(filepath, tests)a.NoError(err)}@@ -395,7 +390,7 @@ func readTestData(path string) ([]test, error) {}type yamlStruct struct {Statement string- Result []any+ Result []stringRun bool}var yamlTests []yamlStruct@@ -410,12 +405,8 @@ func readTestData(path string) ([]test, error) {Run: yamlTest.Run,}for _, r := range yamlTest.Result {- jsonData, err := json.MarshalIndent(r, "", " ")- if err != nil {- return nil, err- }result := &v1pb.PlanCheckRun_Result{}- if err := protojson.Unmarshal(jsonData, result); err != nil {+ if err := protojson.Unmarshal([]byte(r), result); err != nil {return nil, err}t.Result = append(t.Result, result)@@ -425,6 +416,36 @@ func readTestData(path string) ([]test, error) {return tests, nil}+func writeTestData(filepath string, tests []test) error {+ type yamlStruct struct {+ Statement string+ Result []string+ Run bool+ }++ var yamlTests []yamlStruct+ for _, t := range tests {+ yamlTest := yamlStruct{+ Statement: t.Statement,+ Run: t.Run,+ }+ for _, r := range t.Result {+ yamlTest.Result = append(yamlTest.Result, protojson.Format(r))+ }+ yamlTests = append(yamlTests, yamlTest)+ }++ byteValue, err := yaml.Marshal(yamlTests)+ if err != nil {+ return err+ }+ err = os.WriteFile(filepath, byteValue, 0644)+ if err != nil {+ return err+ }+ return nil+}+func createIssueAndReturnSQLReviewResult(ctx context.Context, a *require.Assertions, ctl *controller, project *v1pb.Project, database *v1pb.Database, statement string, wait bool) []*v1pb.PlanCheckRun_Result {sheet, err := ctl.sheetServiceClient.CreateSheet(ctx, &v1pb.CreateSheetRequest{Parent: project.Name,@@ -492,10 +513,7 @@ func createIssueAndReturnSQLReviewResult(ctx context.Context, a *require.Assertifunc equalReviewResultProtos(a *require.Assertions, want, got []*v1pb.PlanCheckRun_Result, message string) {a.Equal(len(want), len(got))for i := 0; i < len(want); i++ {- wantJSON, err := protojson.Marshal(want[i])- a.NoError(err)- gotJSON, err := protojson.Marshal(got[i])- a.NoError(err)- a.Equal(string(wantJSON), string(gotJSON), message)+ diff := cmp.Diff(want[i], got[i], protocmp.Transform())+ a.Equal("", diff, message)}}diff --git a/backend/tests/test-data/sql_review_mysql.yaml b/backend/tests/test-data/sql_review_mysql.yamlindex 24bec153a1..f705471b28 100644--- a/backend/tests/test-data/sql_review_mysql.yaml+++ b/backend/tests/test-data/sql_review_mysql.yaml@@ -1,405 +1,563 @@- statement: CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment',room_id INT NOT NULL DEFAULT 0 COMMENT 'comment',creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment',created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment',updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment',updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',INDEX idx_user_name(name),UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment'result:- - code: 0- status: 3- title: OK+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: false- statement: CREATE TABLE user(id);result:- - status: 1- title: Syntax error- content: |-- Syntax error at line 1:20- related text: CREATE TABLE user(id)- sql_review_report:- code: 201- line: 1- column: 20+ - |-+ {+ "status": "ERROR",+ "title": "Syntax error",+ "content": "Syntax error at line 1:20 \nrelated text: CREATE TABLE user(id)",+ "sqlReviewReport": {+ "line": 1,+ "column": 20,+ "code": 201+ }+ }run: false- statement: CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_binresult:- - status: 1- title: engine.mysql.use-innodb- content: |-- "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin- ;" doesn't use InnoDB engine- sql_review_report:- code: 501- line: 2- - status: 1- title: table.require-pk- content: Table `userTable` requires PRIMARY KEY- sql_review_report:- code: 601- line: 2- - status: 1- title: table.no-foreign-key- content: Foreign key is not allowed in the table `userTable`- sql_review_report:- code: 602- line: 1- - status: 1- title: column.type-disallow-list- content: Disallow column type JSON but column `userTable`.`json_content` is- sql_review_report:- code: 411- line: 1- - status: 2- title: naming.table- content: '`userTable` mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- sql_review_report:- code: 301- line: 2- - status: 2- title: naming.column- content: '`userTable`.`roomId` mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- sql_review_report:- code: 302- line: 1- - status: 2- title: naming.index.idx- content: Index in table `userTable` mismatches the naming convention, expect "^$|^idx_userTable_name$" but found `idx1`- sql_review_report:- code: 303- line: 1- - status: 2- title: naming.index.uk- content: Unique key in table `userTable` mismatches the naming convention, expect "^$|^uk_userTable_id_name$" but found `uk1`- sql_review_report:- code: 304- line: 1- - status: 2- title: naming.index.fk- content: Foreign key in table `userTable` mismatches the naming convention, expect "^$|^fk_userTable_roomId_room_id$" but found `fk1`- sql_review_report:- code: 305- line: 1- - status: 2- title: table.comment- content: Table `userTable` requires comments- sql_review_report:- code: 605- line: 2- - status: 2- title: column.required- content: "Table `userTable` requires columns: created_ts, creator_id, updated_ts, updater_id"- sql_review_report:- code: 401- line: 2- - status: 2- title: column.no-null- content: "`userTable`.`name` cannot have NULL value"- sql_review_report:- code: 402- line: 1- - status: 2- title: column.no-null- content: "`userTable`.`roomId` cannot have NULL value"- sql_review_report:- code: 402- line: 1- - status: 2- title: column.set-default-for-not-null- content: Column `userTable`.`id` is NOT NULL but doesn't have DEFAULT- sql_review_report:- code: 404- line: 1- - status: 2- title: column.comment- content: Column `userTable`.`id` requires comments- sql_review_report:- code: 408- line: 1- - status: 2- title: column.comment- content: Column `userTable`.`name` requires comments- sql_review_report:- code: 408- line: 1- - status: 2- title: column.comment- content: Column `userTable`.`roomId` requires comments- sql_review_report:- code: 408- line: 1- - status: 2- title: column.disallow-set-charset- content: |-- Disallow set column charset but "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin- ;" does- sql_review_report:- code: 414- line: 2- - status: 2- title: column.current-time-count-limit- content: Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.- sql_review_report:- code: 419- line: 2- - status: 2- title: column.require-default- content: Column `userTable`.`id` doesn't have DEFAULT.- sql_review_report:- code: 420- line: 1- - status: 2- title: column.require-default- content: Column `userTable`.`name` doesn't have DEFAULT.- sql_review_report:- code: 420- line: 1- - status: 2- title: column.require-default- content: Column `userTable`.`roomId` doesn't have DEFAULT.- sql_review_report:- code: 420- line: 1- - status: 2- title: index.type-no-blob- content: Columns in index must not be BLOB but `userTable`.`content` is blob- sql_review_report:- code: 804- line: 1- - status: 2- title: system.charset.allowlist- content: |-- "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin- ;" used disabled charset 'ascii'- sql_review_report:- code: 1001- line: 1- - status: 2- title: system.collation.allowlist- content: |-- "CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin- ;" used disabled collation 'latin1_bin'- sql_review_report:- code: 1201- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "engine.mysql.use-innodb",+ "content": "\"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin\n;\" doesn't use InnoDB engine",+ "sqlReviewReport": {+ "line": 2,+ "code": 501+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "table.require-pk",+ "content": "Table `userTable` requires PRIMARY KEY",+ "sqlReviewReport": {+ "line": 2,+ "code": 601+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "table.no-foreign-key",+ "content": "Foreign key is not allowed in the table `userTable`",+ "sqlReviewReport": {+ "line": 1,+ "code": 602+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "column.type-disallow-list",+ "content": "Disallow column type JSON but column `userTable`.`json_content` is",+ "sqlReviewReport": {+ "line": 1,+ "code": 411+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.table",+ "content": "`userTable` mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",+ "sqlReviewReport": {+ "line": 2,+ "code": 301+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.column",+ "content": "`userTable`.`roomId` mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",+ "sqlReviewReport": {+ "line": 1,+ "code": 302+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.index.idx",+ "content": "Index in table `userTable` mismatches the naming convention, expect \"^$|^idx_userTable_name$\" but found `idx1`",+ "sqlReviewReport": {+ "line": 1,+ "code": 303+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.index.uk",+ "content": "Unique key in table `userTable` mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found `uk1`",+ "sqlReviewReport": {+ "line": 1,+ "code": 304+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.index.fk",+ "content": "Foreign key in table `userTable` mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found `fk1`",+ "sqlReviewReport": {+ "line": 1,+ "code": 305+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "table.comment",+ "content": "Table `userTable` requires comments",+ "sqlReviewReport": {+ "line": 2,+ "code": 605+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.required",+ "content": "Table `userTable` requires columns: created_ts, creator_id, updated_ts, updater_id",+ "sqlReviewReport": {+ "line": 2,+ "code": 401+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.no-null",+ "content": "`userTable`.`name` cannot have NULL value",+ "sqlReviewReport": {+ "line": 1,+ "code": 402+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.no-null",+ "content": "`userTable`.`roomId` cannot have NULL value",+ "sqlReviewReport": {+ "line": 1,+ "code": 402+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.set-default-for-not-null",+ "content": "Column `userTable`.`id` is NOT NULL but doesn't have DEFAULT",+ "sqlReviewReport": {+ "line": 1,+ "code": 404+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.comment",+ "content": "Column `userTable`.`id` requires comments",+ "sqlReviewReport": {+ "line": 1,+ "code": 408+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.comment",+ "content": "Column `userTable`.`name` requires comments",+ "sqlReviewReport": {+ "line": 1,+ "code": 408+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.comment",+ "content": "Column `userTable`.`roomId` requires comments",+ "sqlReviewReport": {+ "line": 1,+ "code": 408+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.disallow-set-charset",+ "content": "Disallow set column charset but \"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin\n;\" does",+ "sqlReviewReport": {+ "line": 2,+ "code": 414+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.current-time-count-limit",+ "content": "Table `userTable` has 2 ON UPDATE CURRENT_TIMESTAMP() columns. The count greater than 1.",+ "sqlReviewReport": {+ "line": 2,+ "code": 419+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.require-default",+ "content": "Column `userTable`.`id` doesn't have DEFAULT.",+ "sqlReviewReport": {+ "line": 1,+ "code": 420+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.require-default",+ "content": "Column `userTable`.`name` doesn't have DEFAULT.",+ "sqlReviewReport": {+ "line": 1,+ "code": 420+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.require-default",+ "content": "Column `userTable`.`roomId` doesn't have DEFAULT.",+ "sqlReviewReport": {+ "line": 1,+ "code": 420+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "index.type-no-blob",+ "content": "Columns in index must not be BLOB but `userTable`.`content` is blob",+ "sqlReviewReport": {+ "line": 1,+ "code": 804+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "system.charset.allowlist",+ "content": "\"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin\n;\" used disabled charset 'ascii'",+ "sqlReviewReport": {+ "line": 1,+ "code": 1001+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "system.collation.allowlist",+ "content": "\"CREATE TABLE userTable(id INT NOT NULL,name VARCHAR(255) CHARSET ascii,roomId INT,time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',content BLOB NOT NULL COMMENT 'comment',json_content JSON NOT NULL COMMENT 'comment',INDEX idx1(name),UNIQUE KEY uk1(id, name),FOREIGN KEY fk1(roomId) REFERENCES room(id),INDEX idx_userTable_content(content)) ENGINE = CSV COLLATE latin1_bin\n;\" used disabled collation 'latin1_bin'",+ "sqlReviewReport": {+ "line": 2,+ "code": 1201+ }+ }run: false- statement: CREATE TABLE t_auto(auto_id varchar(20) AUTO_INCREMENT PRIMARY KEY COMMENT 'COMMENT') auto_increment = 2 COMMENT 'comment'result:- - status: 1- title: column.auto-increment-must-integer- content: Auto-increment column `t_auto`.`auto_id` requires integer type- sql_review_report:- code: 410- line: 2- - status: 2- title: naming.column.auto-increment- content: '`t_auto`.`auto_id` mismatches auto_increment column naming convention, naming format should be "^id$"'- sql_review_report:- code: 307- line: 1- - status: 2- title: column.required- content: "Table `t_auto` requires columns: created_ts, creator_id, id, updated_ts, updater_id"- sql_review_report:- code: 401- line: 2- - status: 2- title: column.auto-increment-initial-value- content: The initial auto-increment value in table `t_auto` is 2, which doesn't equal 20- sql_review_report:- code: 416- line: 2- - status: 2- title: column.auto-increment-must-unsigned- content: Auto-increment column `t_auto`.`auto_id` is not UNSIGNED type- sql_review_report:- code: 417- line: 2- - status: 2- title: index.pk-type-limit- content: Columns in primary key must be INT/BIGINT but `t_auto`.`auto_id` is varchar(20)- sql_review_report:- code: 803- line: 1+ - |-+ {+ "status": "ERROR",+ "title": "column.auto-increment-must-integer",+ "content": "Auto-increment column `t_auto`.`auto_id` requires integer type",+ "sqlReviewReport": {+ "line": 2,+ "code": 410+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.column.auto-increment",+ "content": "`t_auto`.`auto_id` mismatches auto_increment column naming convention, naming format should be \"^id$\"",+ "sqlReviewReport": {+ "line": 1,+ "code": 307+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.required",+ "content": "Table `t_auto` requires columns: created_ts, creator_id, id, updated_ts, updater_id",+ "sqlReviewReport": {+ "line": 2,+ "code": 401+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.auto-increment-initial-value",+ "content": "The initial auto-increment value in table `t_auto` is 2, which doesn't equal 20",+ "sqlReviewReport": {+ "line": 2,+ "code": 416+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.auto-increment-must-unsigned",+ "content": "Auto-increment column `t_auto`.`auto_id` is not UNSIGNED type",+ "sqlReviewReport": {+ "line": 2,+ "code": 417+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "index.pk-type-limit",+ "content": "Columns in primary key must be INT/BIGINT but `t_auto`.`auto_id` is varchar(20)",+ "sqlReviewReport": {+ "line": 1,+ "code": 803+ }+ }run: false-- statement: " DELETE FROM tech_book"+- statement: ' DELETE FROM tech_book'result:- - status: 1- title: statement.where.require- content: |-- " DELETE FROM tech_book- ;" requires WHERE clause- sql_review_report:- code: 202- line: 2- - status: 1- title: statement.dml-dry-run- content: |-- " DELETE FROM tech_book- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist- sql_review_report:- code: 208- line: 2- - status: 2- title: statement.affected-row-limit- content: |-- " DELETE FROM tech_book- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist- sql_review_report:- code: 209- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "statement.where.require",+ "content": "\" DELETE FROM tech_book\n;\" requires WHERE clause",+ "sqlReviewReport": {+ "line": 2,+ "code": 202+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "statement.dml-dry-run",+ "content": "\" DELETE FROM tech_book\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 208+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "statement.affected-row-limit",+ "content": "\" DELETE FROM tech_book\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 209+ }+ }run: false- statement: DELETE FROM tech_book WHERE name like `%abc`result:- - status: 1- title: statement.where.no-leading-wildcard-like- content: |-- "DELETE FROM tech_book WHERE name like `%abc`- ;" uses leading wildcard LIKE- sql_review_report:- code: 204- line: 2- - status: 1- title: statement.dml-dry-run- content: |-- "DELETE FROM tech_book WHERE name like `%abc`- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist- sql_review_report:- code: 208- line: 2- - status: 2- title: statement.affected-row-limit- content: |-- "DELETE FROM tech_book WHERE name like `%abc`- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist- sql_review_report:- code: 209- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "statement.where.no-leading-wildcard-like",+ "content": "\"DELETE FROM tech_book WHERE name like `%abc`\n;\" uses leading wildcard LIKE",+ "sqlReviewReport": {+ "line": 2,+ "code": 204+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "statement.dml-dry-run",+ "content": "\"DELETE FROM tech_book WHERE name like `%abc`\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 208+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "statement.affected-row-limit",+ "content": "\"DELETE FROM tech_book WHERE name like `%abc`\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 209+ }+ }run: false-- statement: " INSERT INTO t_copy SELECT * FROM t"+- statement: ' INSERT INTO t_copy SELECT * FROM t'result:- - status: 1- title: statement.select.no-select-all- content: |-- " INSERT INTO t_copy SELECT * FROM t- ;" uses SELECT all- sql_review_report:- code: 203- line: 2- - status: 1- title: statement.where.require- content: |-- " INSERT INTO t_copy SELECT * FROM t- ;" requires WHERE clause- sql_review_report:- code: 202- line: 2- - status: 1- title: statement.dml-dry-run- content: |-- " INSERT INTO t_copy SELECT * FROM t- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist- sql_review_report:- code: 208- line: 2- - status: 2- title: statement.insert.row-limit- content: |-- " INSERT INTO t_copy SELECT * FROM t- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist- sql_review_report:- code: 1101- line: 2- - status: 2- title: statement.insert.must-specify-column- content: |-- The INSERT statement must specify columns but " INSERT INTO t_copy SELECT * FROM t- ;" does not- sql_review_report:- code: 1107- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "statement.select.no-select-all",+ "content": "\" INSERT INTO t_copy SELECT * FROM t\n;\" uses SELECT all",+ "sqlReviewReport": {+ "line": 2,+ "code": 203+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "statement.where.require",+ "content": "\" INSERT INTO t_copy SELECT * FROM t\n;\" requires WHERE clause",+ "sqlReviewReport": {+ "line": 2,+ "code": 202+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "statement.dml-dry-run",+ "content": "\" INSERT INTO t_copy SELECT * FROM t\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 208+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "statement.insert.row-limit",+ "content": "\" INSERT INTO t_copy SELECT * FROM t\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t_copy' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 1101+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "statement.insert.must-specify-column",+ "content": "The INSERT statement must specify columns but \" INSERT INTO t_copy SELECT * FROM t\n;\" does not",+ "sqlReviewReport": {+ "line": 2,+ "code": 1107+ }+ }run: false-- statement: " INSERT INTO t VALUES (1, 1, now(), 1, now())"+- statement: ' INSERT INTO t VALUES (1, 1, now(), 1, now())'result:- - status: 1- title: statement.dml-dry-run- content: |-- " INSERT INTO t VALUES (1, 1, now(), 1, now())- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t' doesn't exist- sql_review_report:- code: 208- line: 2- - status: 2- title: statement.insert.must-specify-column- content: |-- The INSERT statement must specify columns but " INSERT INTO t VALUES (1, 1, now(), 1, now())- ;" does not- sql_review_report:- code: 1107- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "statement.dml-dry-run",+ "content": "\" INSERT INTO t VALUES (1, 1, now(), 1, now())\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.t' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 208+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "statement.insert.must-specify-column",+ "content": "The INSERT statement must specify columns but \" INSERT INTO t VALUES (1, 1, now(), 1, now())\n;\" does not",+ "sqlReviewReport": {+ "line": 2,+ "code": 1107+ }+ }run: false- statement: DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')result:- - status: 1- title: statement.dml-dry-run- content: |-- "DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist- sql_review_report:- code: 208- line: 2- - status: 2- title: statement.affected-row-limit- content: |-- "DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')- ;" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist- sql_review_report:- code: 209- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "statement.dml-dry-run",+ "content": "\"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 208+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "statement.affected-row-limit",+ "content": "\"DELETE FROM tech_book WHERE id = (SELECT max(id) FROM tech_book WHERE name = 'bytebase')\n;\" dry runs failed: Error 1146 (42S02): Table 'testsqlreview.tech_book' doesn't exist",+ "sqlReviewReport": {+ "line": 2,+ "code": 209+ }+ }run: false- statement: COMMIT;result:- - status: 1- title: statement.disallow-commit- content: |-- Commit is not allowed, related statement: "COMMIT- ;"- sql_review_report:- code: 206- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "statement.disallow-commit",+ "content": "Commit is not allowed, related statement: \"COMMIT\n;\"",+ "sqlReviewReport": {+ "line": 2,+ "code": 206+ }+ }run: false- statement: CREATE TABLE user(id INT PRIMARY KEY COMMENT 'comment',name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment',room_id INT NOT NULL DEFAULT 0 COMMENT 'comment',creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment',created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment',updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment',updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment',INDEX idx_user_name(name),UNIQUE KEY uk_user_id_name(id, name)) ENGINE = INNODB COMMENT 'comment'result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: true- statement: INSERT INTO user(id, name) values (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e')result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: true- statement: DELETE FROM user WHERE id < 10result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: false- statement: INSERT INTO user(id, name) values (6, 'f'), (7, 'g'), (8, 'h'), (9, 'i'), (10, 'j')result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: true- statement: DELETE FROM user WHERE id <= 10result:- - status: 2- title: statement.affected-row-limit- content: |-- "DELETE FROM user WHERE id <= 10- ;" affected 10 rows. The count exceeds 5.- sql_review_report:- code: 209- line: 2+ - |-+ {+ "status": "WARNING",+ "title": "statement.affected-row-limit",+ "content": "\"DELETE FROM user WHERE id <= 10\n;\" affected 10 rows. The count exceeds 5.",+ "sqlReviewReport": {+ "line": 2,+ "code": 209+ }+ }run: false- statement: |-INSERT INTO user(id, name) SELECT id, name FROM (SELECT 1 AS id, 'a' AS name WHERE 1=1 UNION ALL@@ -413,95 +571,118 @@SELECT 9 AS id, 'i' AS name WHERE 1=1 UNION ALLSELECT 10 AS id, 'j' AS name WHERE 1=1) value_table WHERE 1=1result:- - status: 2- title: statement.insert.row-limit- content: |-- "INSERT INTO user(id, name) SELECT id, name FROM (SELECT 1 AS id, 'a' AS name WHERE 1=1 UNION ALL- SELECT 2 AS id, 'b' AS name WHERE 1=1 UNION ALL- SELECT 3 AS id, 'c' AS name WHERE 1=1 UNION ALL- SELECT 4 AS id, 'd' AS name WHERE 1=1 UNION ALL- SELECT 5 AS id, 'e' AS name WHERE 1=1 UNION ALL- SELECT 6 AS id, 'f' AS name WHERE 1=1 UNION ALL- SELECT 7 AS id, 'g' AS name WHERE 1=1 UNION ALL- SELECT 8 AS id, 'h' AS name WHERE 1=1 UNION ALL- SELECT 9 AS id, 'i' AS name WHERE 1=1 UNION ALL- SELECT 10 AS id, 'j' AS name WHERE 1=1) value_table WHERE 1=1- ;" inserts 10 rows. The count exceeds 5.- sql_review_report:- code: 1101- line: 11+ - |-+ {+ "status": "WARNING",+ "title": "statement.insert.row-limit",+ "content": "\"INSERT INTO user(id, name) SELECT id, name FROM (SELECT 1 AS id, 'a' AS name WHERE 1=1 UNION ALL\n SELECT 2 AS id, 'b' AS name WHERE 1=1 UNION ALL\n SELECT 3 AS id, 'c' AS name WHERE 1=1 UNION ALL\n SELECT 4 AS id, 'd' AS name WHERE 1=1 UNION ALL\n SELECT 5 AS id, 'e' AS name WHERE 1=1 UNION ALL\n SELECT 6 AS id, 'f' AS name WHERE 1=1 UNION ALL\n SELECT 7 AS id, 'g' AS name WHERE 1=1 UNION ALL\n SELECT 8 AS id, 'h' AS name WHERE 1=1 UNION ALL\n SELECT 9 AS id, 'i' AS name WHERE 1=1 UNION ALL\n SELECT 10 AS id, 'j' AS name WHERE 1=1) value_table WHERE 1=1\n;\" inserts 10 rows. The count exceeds 5.",+ "sqlReviewReport": {+ "line": 11,+ "code": 1101+ }+ }run: false- statement: INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1result:- - status: 2- title: statement.disallow-limit- content: |-- LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but "INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1- ;" uses- sql_review_report:- code: 1103- line: 2+ - |-+ {+ "status": "WARNING",+ "title": "statement.disallow-limit",+ "content": "LIMIT clause is forbidden in INSERT, UPDATE and DELETE statement, but \"INSERT INTO user(id, name) SELECT id, name FROM user WHERE id=1 LIMIT 1\n;\" uses",+ "sqlReviewReport": {+ "line": 2,+ "code": 1103+ }+ }run: false-- statement: " ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;"+- statement: ' ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8;'result:- - status: 2- title: table.disallow-partition- content: |-- Table partition is forbidden, but " ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8- ;" creates- sql_review_report:- code: 608- line: 2+ - |-+ {+ "status": "WARNING",+ "title": "table.disallow-partition",+ "content": "Table partition is forbidden, but \" ALTER TABLE user PARTITION BY HASH(id) PARTITIONS 8\n;\" creates",+ "sqlReviewReport": {+ "line": 2,+ "code": 608+ }+ }run: false- statement: |-ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;ALTER TABLE user ADD COLUMN c_column int NOT NULL DEFAULT 0 COMMENT 'comment';result:- - status: 2- title: statement.merge-alter-table- content: There are 2 statements to modify table `user`- sql_review_report:- code: 207- line: 3- - status: 2- title: column.disallow-change-type- content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" changes column type'- sql_review_report:- code: 403- line: 1- - status: 2- title: column.disallow-change- content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" contains CHANGE COLUMN statement'- sql_review_report:- code: 406- line: 1- - status: 2- title: column.disallow-changing-order- content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" changes column order'- sql_review_report:- code: 407- line: 1- - status: 2- title: schema.backward-compatibility- content: '"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '''' COMMENT ''COMMENT'' FIRST;" may cause incompatibility with the existing data and code'- sql_review_report:- code: 111- line: 1+ - |-+ {+ "status": "WARNING",+ "title": "statement.merge-alter-table",+ "content": "There are 2 statements to modify table `user`",+ "sqlReviewReport": {+ "line": 3,+ "code": 207+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.disallow-change-type",+ "content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" changes column type",+ "sqlReviewReport": {+ "line": 1,+ "code": 403+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.disallow-change",+ "content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" contains CHANGE COLUMN statement",+ "sqlReviewReport": {+ "line": 1,+ "code": 406+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.disallow-changing-order",+ "content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" changes column order",+ "sqlReviewReport": {+ "line": 1,+ "code": 407+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "schema.backward-compatibility",+ "content": "\"ALTER TABLE user CHANGE name name varchar(320) NOT NULL DEFAULT '' COMMENT 'COMMENT' FIRST;\" may cause incompatibility with the existing data and code",+ "sqlReviewReport": {+ "line": 1,+ "code": 111+ }+ }run: false-- statement: " DROP TABLE user;"+- statement: ' DROP TABLE user;'result:- - status: 1- title: table.drop-naming-convention- content: '`user` mismatches drop table naming convention, naming format should be "_delete$"'- sql_review_report:- code: 603- line: 2- - status: 2- title: schema.backward-compatibility- content: |-- " DROP TABLE user- ;" may cause incompatibility with the existing data and code- sql_review_report:- code: 103- line: 2+ - |-+ {+ "status": "ERROR",+ "title": "table.drop-naming-convention",+ "content": "`user` mismatches drop table naming convention, naming format should be \"_delete$\"",+ "sqlReviewReport": {+ "line": 2,+ "code": 603+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "schema.backward-compatibility",+ "content": "\" DROP TABLE user\n;\" may cause incompatibility with the existing data and code",+ "sqlReviewReport": {+ "line": 2,+ "code": 103+ }+ }run: falsediff --git a/backend/tests/test-data/sql_review_pg.yaml b/backend/tests/test-data/sql_review_pg.yamlindex 3bdd29b780..2cf5197d73 100644--- a/backend/tests/test-data/sql_review_pg.yaml+++ b/backend/tests/test-data/sql_review_pg.yaml@@ -11,18 +11,24 @@CONSTRAINT uk_user_id_name UNIQUE (id, name))result:- - code: 0- title: OK- status: 3+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: false- statement: CREATE TABLE user(id);result:- - status: 1- title: Syntax error- content: syntax error at or near "user"- sql_review_report:- code: 201- line: 1+ - |-+ {+ "status": "ERROR",+ "title": "Syntax error",+ "content": "syntax error at or near \"user\"",+ "sqlReviewReport": {+ "line": 1,+ "code": 201+ }+ }run: false- statement: |-CREATE TABLE "userTable"(@@ -33,105 +39,148 @@CONSTRAINT fk1 FOREIGN KEY ("roomId") REFERENCES room(id))result:- - status: 1- title: table.require-pk- content: 'Table "public"."userTable" requires PRIMARY KEY, related statement: "CREATE TABLE \"userTable\"(\n id INT,\n name VARCHAR(255),\n \"roomId\" INT,\n CONSTRAINT uk1 UNIQUE (id, name),\n CONSTRAINT fk1 FOREIGN KEY (\"roomId\") REFERENCES room(id)\n )"'- sql_review_report:- code: 601- line: 7- - status: 1- title: table.no-foreign-key- content: |-- Foreign key is not allowed in the table "public"."userTable", related statement: "CREATE TABLE "userTable"(- id INT,- name VARCHAR(255),- "roomId" INT,- CONSTRAINT uk1 UNIQUE (id, name),- CONSTRAINT fk1 FOREIGN KEY ("roomId") REFERENCES room(id)- )"- sql_review_report:- code: 602- line: 7- - status: 2- title: naming.table- content: '"userTable" mismatches table naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- sql_review_report:- code: 301- line: 7- - status: 2- title: naming.column- content: '"userTable"."roomId" mismatches column naming convention, naming format should be "^[a-z]+(_[a-z]+)*$"'- sql_review_report:- code: 302- line: 4- - status: 2- title: naming.index.uk- content: Unique key in table "userTable" mismatches the naming convention, expect "^$|^uk_userTable_id_name$" but found "uk1"- sql_review_report:- line: 5- code: 304- - status: 2- title: naming.index.fk- content: Foreign key in table "userTable" mismatches the naming convention, expect "^$|^fk_userTable_roomId_room_id$" but found "fk1"- sql_review_report:- code: 305- line: 6- - status: 2- title: column.required- content: 'Table "userTable" requires columns: created_ts, creator_id, updated_ts, updater_id'- sql_review_report:- code: 401- line: 7- - status: 2- title: column.no-null- content: Column "id" in "public"."userTable" cannot have NULL value- sql_review_report:- line: 2- code: 402- - status: 2- title: column.no-null- content: Column "name" in "public"."userTable" cannot have NULL value- sql_review_report:- code: 402- line: 3- - status: 2- title: column.no-null- content: Column "roomId" in "public"."userTable" cannot have NULL value- sql_review_report:- code: 402- line: 4+ - |-+ {+ "status": "ERROR",+ "title": "table.require-pk",+ "content": "Table \"public\".\"userTable\" requires PRIMARY KEY, related statement: \"CREATE TABLE \\\"userTable\\\"(\\n id INT,\\n name VARCHAR(255),\\n \\\"roomId\\\" INT,\\n CONSTRAINT uk1 UNIQUE (id, name),\\n CONSTRAINT fk1 FOREIGN KEY (\\\"roomId\\\") REFERENCES room(id)\\n )\"",+ "sqlReviewReport": {+ "line": 7,+ "code": 601+ }+ }+ - |-+ {+ "status": "ERROR",+ "title": "table.no-foreign-key",+ "content": "Foreign key is not allowed in the table \"public\".\"userTable\", related statement: \"CREATE TABLE \"userTable\"(\n id INT,\n name VARCHAR(255),\n \"roomId\" INT,\n CONSTRAINT uk1 UNIQUE (id, name),\n CONSTRAINT fk1 FOREIGN KEY (\"roomId\") REFERENCES room(id)\n )\"",+ "sqlReviewReport": {+ "line": 7,+ "code": 602+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.table",+ "content": "\"userTable\" mismatches table naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",+ "sqlReviewReport": {+ "line": 7,+ "code": 301+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.column",+ "content": "\"userTable\".\"roomId\" mismatches column naming convention, naming format should be \"^[a-z]+(_[a-z]+)*$\"",+ "sqlReviewReport": {+ "line": 4,+ "code": 302+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.index.uk",+ "content": "Unique key in table \"userTable\" mismatches the naming convention, expect \"^$|^uk_userTable_id_name$\" but found \"uk1\"",+ "sqlReviewReport": {+ "line": 5,+ "code": 304+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "naming.index.fk",+ "content": "Foreign key in table \"userTable\" mismatches the naming convention, expect \"^$|^fk_userTable_roomId_room_id$\" but found \"fk1\"",+ "sqlReviewReport": {+ "line": 6,+ "code": 305+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.required",+ "content": "Table \"userTable\" requires columns: created_ts, creator_id, updated_ts, updater_id",+ "sqlReviewReport": {+ "line": 7,+ "code": 401+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.no-null",+ "content": "Column \"id\" in \"public\".\"userTable\" cannot have NULL value",+ "sqlReviewReport": {+ "line": 2,+ "code": 402+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.no-null",+ "content": "Column \"name\" in \"public\".\"userTable\" cannot have NULL value",+ "sqlReviewReport": {+ "line": 3,+ "code": 402+ }+ }+ - |-+ {+ "status": "WARNING",+ "title": "column.no-null",+ "content": "Column \"roomId\" in \"public\".\"userTable\" cannot have NULL value",+ "sqlReviewReport": {+ "line": 4,+ "code": 402+ }+ }run: false- statement: DELETE FROM tresult:- - status: 1- title: statement.where.require- content: '"DELETE FROM t" requires WHERE clause'- sql_review_report:- code: 202- line: 1+ - |-+ {+ "status": "ERROR",+ "title": "statement.where.require",+ "content": "\"DELETE FROM t\" requires WHERE clause",+ "sqlReviewReport": {+ "line": 1,+ "code": 202+ }+ }run: false- statement: DELETE FROM t WHERE a like '%abc'result:- - status: 1- title: statement.where.no-leading-wildcard-like- content: '"DELETE FROM t WHERE a like ''%abc''" uses leading wildcard LIKE'- sql_review_report:- code: 204- line: 1+ - |-+ {+ "status": "ERROR",+ "title": "statement.where.no-leading-wildcard-like",+ "content": "\"DELETE FROM t WHERE a like '%abc'\" uses leading wildcard LIKE",+ "sqlReviewReport": {+ "line": 1,+ "code": 204+ }+ }run: false- statement: DELETE FROM t WHERE a = (SELECT max(id) FROM "user" WHERE name = 'bytebase')result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: false- statement: INSERT INTO t VALUES (1), (2)result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: false- statement: |-CREATE TABLE tech_book(@@ -143,17 +192,22 @@CONSTRAINT pk_tech_book_id PRIMARY KEY (id))result:- - code: 0- status: 3- title: OK- content: ""+ - |-+ {+ "status": "SUCCESS",+ "title": "OK"+ }run: true- statement: ALTER INDEX pk_tech_book_id RENAME TO pk1result:- - status: 2- title: naming.index.pk- content: Primary key in table "tech_book" mismatches the naming convention, expect "^$|^pk_tech_book_id$" but found "pk1"- sql_review_report:- code: 306- line: 1+ - |-+ {+ "status": "WARNING",+ "title": "naming.index.pk",+ "content": "Primary key in table \"tech_book\" mismatches the naming convention, expect \"^$|^pk_tech_book_id$\" but found \"pk1\"",+ "sqlReviewReport": {+ "line": 1,+ "code": 306+ }+ }run: false