MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestValidateSQLForEditor

Function TestValidateSQLForEditor

backend/plugin/parser/mysql/query_test.go:11–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestValidateSQLForEditor(t *testing.T) {
12 tests := []struct {
13 statement string
14 valid bool
15 gotAllQuery bool
16 err bool
17 }{
18 {
19 statement: "SHOW CREATE TABLE bytebase;",
20 valid: true,
21 gotAllQuery: true,
22 },
23 {
24 statement: "DESC bytebase;",
25 valid: true,
26 gotAllQuery: true,
27 },
28 {
29 statement: "SELECT * FROM t1 WHERE c1 = 1; SELECT * FROM t2;",
30 valid: true,
31 gotAllQuery: true,
32 },
33 {
34 statement: "CREATE TABLE t1 (c1 INT);",
35 valid: false,
36 gotAllQuery: false,
37 },
38 {
39 statement: "UPDATE t1 SET c1 = 1;",
40 valid: false,
41 gotAllQuery: false,
42 },
43 {
44 statement: "EXPLAIN SELECT * FROM t1;",
45 valid: true,
46 gotAllQuery: true,
47 },
48 {
49 statement: "EXPLAIN FORMAT=JSON DELETE FROM t1;",
50 valid: true,
51 gotAllQuery: true,
52 },
53 {
54 statement: `select* from t`,
55 valid: true,
56 gotAllQuery: true,
57 },
58 {
59 statement: `explain select * from t;`,
60 valid: true,
61 gotAllQuery: true,
62 },
63 {
64 statement: `explain analyze select * from t`,
65 valid: false,
66 gotAllQuery: true,
67 },
68 {

Callers

nothing calls this directly

Calls 4

validateQueryFunction · 0.70
EqualMethod · 0.65
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected