(t *testing.T)
| 199 | } |
| 200 | |
| 201 | func TestSQLReviewForMySQL(t *testing.T) { |
| 202 | const ( |
| 203 | record = false |
| 204 | ) |
| 205 | var ( |
| 206 | filepath = filepath.Join("test-data", "sql_review_mysql.yaml") |
| 207 | databaseName = "testsqlreview" |
| 208 | statements = []string{ |
| 209 | "CREATE TABLE user(" + |
| 210 | "id INT PRIMARY KEY COMMENT 'comment'," + |
| 211 | "name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'comment'," + |
| 212 | "room_id INT NOT NULL DEFAULT 0 COMMENT 'comment'," + |
| 213 | "creator_id INT NOT NULL DEFAULT 0 COMMENT 'comment'," + |
| 214 | "created_ts TIMESTAMP NOT NULL DEFAULT NOW() COMMENT 'comment'," + |
| 215 | "updater_id INT NOT NULL DEFAULT 0 COMMENT 'comment'," + |
| 216 | "updated_ts TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment'," + |
| 217 | "INDEX idx_user_name(name)," + |
| 218 | "UNIQUE KEY uk_user_id_name(id, name)" + |
| 219 | ") ENGINE = INNODB COMMENT 'comment'", |
| 220 | "CREATE TABLE userTable(" + |
| 221 | "id INT NOT NULL," + |
| 222 | "name VARCHAR(255) CHARSET ascii," + |
| 223 | "roomId INT," + |
| 224 | "time_created TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment'," + |
| 225 | "time_updated TIMESTAMP NOT NULL DEFAULT NOW() ON UPDATE NOW() COMMENT 'comment'," + |
| 226 | "content BLOB NOT NULL COMMENT 'comment'," + |
| 227 | "json_content JSON NOT NULL COMMENT 'comment'," + |
| 228 | "INDEX idx1(name)," + |
| 229 | "UNIQUE KEY uk1(id, name)," + |
| 230 | "FOREIGN KEY fk1(roomId) REFERENCES room(id)," + |
| 231 | "INDEX idx_userTable_content(content)" + |
| 232 | ") ENGINE = CSV COLLATE latin1_bin", |
| 233 | } |
| 234 | valueTable = `(SELECT 1 AS id, 'a' AS name WHERE 1=1 UNION ALL |
| 235 | SELECT 2 AS id, 'b' AS name WHERE 1=1 UNION ALL |
| 236 | SELECT 3 AS id, 'c' AS name WHERE 1=1 UNION ALL |
| 237 | SELECT 4 AS id, 'd' AS name WHERE 1=1 UNION ALL |
| 238 | SELECT 5 AS id, 'e' AS name WHERE 1=1 UNION ALL |
| 239 | SELECT 6 AS id, 'f' AS name WHERE 1=1 UNION ALL |
| 240 | SELECT 7 AS id, 'g' AS name WHERE 1=1 UNION ALL |
| 241 | SELECT 8 AS id, 'h' AS name WHERE 1=1 UNION ALL |
| 242 | SELECT 9 AS id, 'i' AS name WHERE 1=1 UNION ALL |
| 243 | SELECT 10 AS id, 'j' AS name WHERE 1=1) value_table` |
| 244 | wantQueryResult = &v1pb.QueryResult{ |
| 245 | ColumnNames: []string{"count(*)"}, |
| 246 | ColumnTypeNames: []string{"BIGINT"}, |
| 247 | Masked: []*v1pb.MaskingReason{nil}, |
| 248 | Rows: []*v1pb.QueryRow{ |
| 249 | { |
| 250 | Values: []*v1pb.RowValue{ |
| 251 | {Kind: &v1pb.RowValue_Int64Value{Int64Value: 4}}, |
| 252 | }, |
| 253 | }, |
| 254 | }, |
| 255 | Statement: "SELECT count(*) FROM test WHERE 1=1;", |
| 256 | RowsCount: 1, |
| 257 | } |
| 258 | ) |
nothing calls this directly
no test coverage detected