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

Function TestValidateQuery

backend/plugin/parser/trino/query_test.go:10–103  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestValidateQuery(t *testing.T) {
11 tests := []struct {
12 name string
13 sql string
14 wantReadOnly bool
15 wantData bool
16 wantErr bool
17 }{
18 {
19 name: "Simple SELECT",
20 sql: "SELECT * FROM users",
21 wantReadOnly: true,
22 wantData: true,
23 wantErr: false,
24 },
25 {
26 name: "INSERT statement",
27 sql: "INSERT INTO users (id, name) VALUES (1, 'John')",
28 wantReadOnly: false,
29 wantData: false,
30 wantErr: false,
31 },
32 {
33 name: "UPDATE statement",
34 sql: "UPDATE users SET name = 'John' WHERE id = 1",
35 wantReadOnly: false,
36 wantData: false,
37 wantErr: false,
38 },
39 {
40 name: "DELETE statement",
41 sql: "DELETE FROM users WHERE id = 1",
42 wantReadOnly: false,
43 wantData: false,
44 wantErr: false,
45 },
46 {
47 name: "CREATE TABLE statement",
48 sql: "CREATE TABLE users (id INT, name VARCHAR)",
49 wantReadOnly: false,
50 wantData: false,
51 wantErr: false,
52 },
53 {
54 name: "EXPLAIN statement",
55 sql: "EXPLAIN SELECT * FROM users",
56 wantReadOnly: true,
57 wantData: true,
58 wantErr: false,
59 },
60 {
61 name: "EXPLAIN ANALYZE SELECT",
62 sql: "EXPLAIN ANALYZE SELECT * FROM users",
63 wantReadOnly: true,
64 wantData: true,
65 wantErr: false,
66 },
67 {

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