Skip to content

Commit cddd0f1

Browse files
committed
Ref #447 - Add test cases for TABLE statements
Signed-off-by: William Desportes <williamdes@wdes.fr>
1 parent 876af83 commit cddd0f1

File tree

6 files changed

+368
-0
lines changed

6 files changed

+368
-0
lines changed

tests/Parser/ExplainStatementTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function explainProvider(): array
3636
['parser/parseExplain11'],
3737
['parser/parseExplain12'],
3838
['parser/parseExplain13'],
39+
['parser/parseExplain14'],
3940
['parser/parseExplainErr'],
4041
['parser/parseExplainErr1'],
4142
['parser/parseExplainErr2'],

tests/Parser/SelectStatementTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function selectProvider(): array
102102
['parser/parseSelectGroupBy'],
103103
['parser/parseSelectGroupByErr'],
104104
['parser/parseSelectGroupByWithComments'],
105+
['parser/parseTable1'],
105106
];
106107
}
107108
}

tests/data/parser/parseExplain14.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DESC TABLE `fo` ORDER BY `fo`.`uuid` ASC;

tests/data/parser/parseExplain14.out

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
{
2+
"query": "DESC TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "DESC TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
6+
"len": 41,
7+
"last": 41,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"tokens": [
11+
{
12+
"@type": "PhpMyAdmin\\SqlParser\\Token",
13+
"token": "DESC",
14+
"value": "DESC",
15+
"keyword": "DESC",
16+
"type": 1,
17+
"flags": 3,
18+
"position": 0
19+
},
20+
{
21+
"@type": "PhpMyAdmin\\SqlParser\\Token",
22+
"token": " ",
23+
"value": " ",
24+
"keyword": null,
25+
"type": 3,
26+
"flags": 0,
27+
"position": 4
28+
},
29+
{
30+
"@type": "PhpMyAdmin\\SqlParser\\Token",
31+
"token": "TABLE",
32+
"value": "TABLE",
33+
"keyword": "TABLE",
34+
"type": 1,
35+
"flags": 3,
36+
"position": 5
37+
},
38+
{
39+
"@type": "PhpMyAdmin\\SqlParser\\Token",
40+
"token": " ",
41+
"value": " ",
42+
"keyword": null,
43+
"type": 3,
44+
"flags": 0,
45+
"position": 10
46+
},
47+
{
48+
"@type": "PhpMyAdmin\\SqlParser\\Token",
49+
"token": "`fo`",
50+
"value": "fo",
51+
"keyword": null,
52+
"type": 8,
53+
"flags": 2,
54+
"position": 11
55+
},
56+
{
57+
"@type": "PhpMyAdmin\\SqlParser\\Token",
58+
"token": " ",
59+
"value": " ",
60+
"keyword": null,
61+
"type": 3,
62+
"flags": 0,
63+
"position": 15
64+
},
65+
{
66+
"@type": "PhpMyAdmin\\SqlParser\\Token",
67+
"token": "ORDER BY",
68+
"value": "ORDER BY",
69+
"keyword": "ORDER BY",
70+
"type": 1,
71+
"flags": 7,
72+
"position": 16
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": " ",
77+
"value": " ",
78+
"keyword": null,
79+
"type": 3,
80+
"flags": 0,
81+
"position": 24
82+
},
83+
{
84+
"@type": "PhpMyAdmin\\SqlParser\\Token",
85+
"token": "`fo`",
86+
"value": "fo",
87+
"keyword": null,
88+
"type": 8,
89+
"flags": 2,
90+
"position": 25
91+
},
92+
{
93+
"@type": "PhpMyAdmin\\SqlParser\\Token",
94+
"token": ".",
95+
"value": ".",
96+
"keyword": null,
97+
"type": 2,
98+
"flags": 16,
99+
"position": 29
100+
},
101+
{
102+
"@type": "PhpMyAdmin\\SqlParser\\Token",
103+
"token": "`uuid`",
104+
"value": "uuid",
105+
"keyword": null,
106+
"type": 8,
107+
"flags": 2,
108+
"position": 30
109+
},
110+
{
111+
"@type": "PhpMyAdmin\\SqlParser\\Token",
112+
"token": " ",
113+
"value": " ",
114+
"keyword": null,
115+
"type": 3,
116+
"flags": 0,
117+
"position": 36
118+
},
119+
{
120+
"@type": "PhpMyAdmin\\SqlParser\\Token",
121+
"token": "ASC",
122+
"value": "ASC",
123+
"keyword": "ASC",
124+
"type": 1,
125+
"flags": 3,
126+
"position": 37
127+
},
128+
{
129+
"@type": "PhpMyAdmin\\SqlParser\\Token",
130+
"token": ";",
131+
"value": ";",
132+
"keyword": null,
133+
"type": 9,
134+
"flags": 0,
135+
"position": 40
136+
},
137+
{
138+
"@type": "PhpMyAdmin\\SqlParser\\Token",
139+
"token": null,
140+
"value": null,
141+
"keyword": null,
142+
"type": 9,
143+
"flags": 0,
144+
"position": null
145+
}
146+
],
147+
"count": 15,
148+
"idx": 15
149+
},
150+
"delimiter": ";",
151+
"delimiterLen": 1,
152+
"strict": false,
153+
"errors": []
154+
},
155+
"parser": {
156+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
157+
"list": {
158+
"@type": "@1"
159+
},
160+
"statements": [
161+
{
162+
"@type": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement",
163+
"bodyParser": null,
164+
"statementAlias": "DESC",
165+
"connectionId": null,
166+
"explainedTable": null,
167+
"options": {
168+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
169+
"options": []
170+
},
171+
"first": 0,
172+
"last": 2
173+
}
174+
],
175+
"brackets": 0,
176+
"strict": false,
177+
"errors": []
178+
},
179+
"errors": {
180+
"lexer": [],
181+
"parser": [
182+
[
183+
"Unexpected token.",
184+
{
185+
"@type": "@4"
186+
},
187+
0
188+
],
189+
[
190+
"Unexpected beginning of statement.",
191+
{
192+
"@type": "@6"
193+
},
194+
0
195+
],
196+
[
197+
"Unrecognized statement type.",
198+
{
199+
"@type": "@8"
200+
},
201+
0
202+
]
203+
]
204+
}
205+
}

tests/data/parser/parseTable1.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TABLE `fo` ORDER BY `fo`.`uuid` ASC;

tests/data/parser/parseTable1.out

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"query": "TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
6+
"len": 36,
7+
"last": 36,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"tokens": [
11+
{
12+
"@type": "PhpMyAdmin\\SqlParser\\Token",
13+
"token": "TABLE",
14+
"value": "TABLE",
15+
"keyword": "TABLE",
16+
"type": 1,
17+
"flags": 3,
18+
"position": 0
19+
},
20+
{
21+
"@type": "PhpMyAdmin\\SqlParser\\Token",
22+
"token": " ",
23+
"value": " ",
24+
"keyword": null,
25+
"type": 3,
26+
"flags": 0,
27+
"position": 5
28+
},
29+
{
30+
"@type": "PhpMyAdmin\\SqlParser\\Token",
31+
"token": "`fo`",
32+
"value": "fo",
33+
"keyword": null,
34+
"type": 8,
35+
"flags": 2,
36+
"position": 6
37+
},
38+
{
39+
"@type": "PhpMyAdmin\\SqlParser\\Token",
40+
"token": " ",
41+
"value": " ",
42+
"keyword": null,
43+
"type": 3,
44+
"flags": 0,
45+
"position": 10
46+
},
47+
{
48+
"@type": "PhpMyAdmin\\SqlParser\\Token",
49+
"token": "ORDER BY",
50+
"value": "ORDER BY",
51+
"keyword": "ORDER BY",
52+
"type": 1,
53+
"flags": 7,
54+
"position": 11
55+
},
56+
{
57+
"@type": "PhpMyAdmin\\SqlParser\\Token",
58+
"token": " ",
59+
"value": " ",
60+
"keyword": null,
61+
"type": 3,
62+
"flags": 0,
63+
"position": 19
64+
},
65+
{
66+
"@type": "PhpMyAdmin\\SqlParser\\Token",
67+
"token": "`fo`",
68+
"value": "fo",
69+
"keyword": null,
70+
"type": 8,
71+
"flags": 2,
72+
"position": 20
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": ".",
77+
"value": ".",
78+
"keyword": null,
79+
"type": 2,
80+
"flags": 16,
81+
"position": 24
82+
},
83+
{
84+
"@type": "PhpMyAdmin\\SqlParser\\Token",
85+
"token": "`uuid`",
86+
"value": "uuid",
87+
"keyword": null,
88+
"type": 8,
89+
"flags": 2,
90+
"position": 25
91+
},
92+
{
93+
"@type": "PhpMyAdmin\\SqlParser\\Token",
94+
"token": " ",
95+
"value": " ",
96+
"keyword": null,
97+
"type": 3,
98+
"flags": 0,
99+
"position": 31
100+
},
101+
{
102+
"@type": "PhpMyAdmin\\SqlParser\\Token",
103+
"token": "ASC",
104+
"value": "ASC",
105+
"keyword": "ASC",
106+
"type": 1,
107+
"flags": 3,
108+
"position": 32
109+
},
110+
{
111+
"@type": "PhpMyAdmin\\SqlParser\\Token",
112+
"token": ";",
113+
"value": ";",
114+
"keyword": null,
115+
"type": 9,
116+
"flags": 0,
117+
"position": 35
118+
},
119+
{
120+
"@type": "PhpMyAdmin\\SqlParser\\Token",
121+
"token": null,
122+
"value": null,
123+
"keyword": null,
124+
"type": 9,
125+
"flags": 0,
126+
"position": null
127+
}
128+
],
129+
"count": 13,
130+
"idx": 13
131+
},
132+
"delimiter": ";",
133+
"delimiterLen": 1,
134+
"strict": false,
135+
"errors": []
136+
},
137+
"parser": {
138+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
139+
"list": {
140+
"@type": "@1"
141+
},
142+
"statements": [],
143+
"brackets": 0,
144+
"strict": false,
145+
"errors": []
146+
},
147+
"errors": {
148+
"lexer": [],
149+
"parser": [
150+
[
151+
"Unrecognized statement type.",
152+
{
153+
"@type": "@2"
154+
},
155+
0
156+
]
157+
]
158+
}
159+
}

0 commit comments

Comments
 (0)