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

Function TestValidateSQLForEditor

backend/plugin/parser/tidb/query_test.go:9–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

validateQueryFunction · 0.70
EqualMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected