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

Function TestMySQLCreateTableSetLine

backend/plugin/parser/tidb/tidb_test.go:23–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func TestMySQLCreateTableSetLine(t *testing.T) {
24 tests := []setLineTestData{
25 {
26 statement: "CREATE TABLE t as select * from t1",
27 firstLine: 1,
28 columnLineList: []int{},
29 constraintLineList: []int{},
30 },
31 {
32 statement: "CREATE TABLE t like t1",
33 firstLine: 1,
34 columnLineList: []int{},
35 constraintLineList: []int{},
36 },
37 {
38 statement: `-- this is the first line.
39 CREATE TABLE t(
40 a int, B int,
41 C int,
42 D int NOT NULL,
43 INDEX (a),
44 KEY (a),
45 CONSTRAINT unique_a UNIQUE (a),
46 UNIQUE (b, c),
47 PRIMARY KEY (d),CHECK (a > 0),
48
49 -- it's a comment.
50 FOREIGN KEY (a, b, c) REFERENCES t1(a, b, c)
51
52
53
54
55 )
56 `,
57 firstLine: 1,
58 columnLineList: []int{3, 3, 4, 5},
59 constraintLineList: []int{6, 7, 8, 9, 10, 10, 13},
60 },
61 {
62 // test for Windows.
63 statement: "\r\n" +
64 "CREATE TABLE t(" + "\r\n" +
65 "a int, B int," + "\r\n" +
66 "C int," + "\r\n" +
67 `D int NOT NULL,` + "\r\n" +
68 "CONSTRAINT unique_a UNIQUE (a)," + "\r\n" +
69 "UNIQUE (b, c)," + "\r\n" +
70 "PRIMARY KEY (d),CHECK (a > 0)," + "\r\n" +
71 "\r\n" +
72 "FOREIGN KEY (a, b, c) REFERENCES t1(a, b, c)" + "\r\n" +
73 ")",
74 // Leading \r\n puts the first token (CREATE) on line 2; firstLine is
75 // the first-non-whitespace line per the post-BYT-9381 contract for
76 // node.OriginTextPosition() (SetLineForMySQLCreateTableStmt converts it
77 // back to node.Text()'s char-0 line for the tokenizer).
78 firstLine: 2,
79 columnLineList: []int{3, 3, 4, 5},
80 constraintLineList: []int{6, 7, 8, 8, 10},

Callers

nothing calls this directly

Calls 3

LenMethod · 0.80
EqualMethod · 0.65

Tested by

no test coverage detected