Skip to content

Commit b9f74c1

Browse files
committed
Add tests
Signed-off-by: Liviu-Mihail Concioiu <liviu.concioiu@gmail.com>
1 parent e20618c commit b9f74c1

5 files changed

Lines changed: 444 additions & 0 deletions

tests/Parser/CreateStatementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public static function createProvider(): array
5353
['parser/parseCreateTable16'],
5454
['parser/parseCreateTable17'],
5555
['parser/parseCreateTable18'],
56+
['parser/parseCreateTable19_mariadb_100500'],
57+
['parser/parseCreateTable20_mariadb_101000'],
5658
['parser/parseCreateTableErr1'],
5759
['parser/parseCreateTableErr2'],
5860
['parser/parseCreateTableErr3'],
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE TABLE `test` (`ip` INET6);
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
{
2+
"query": "CREATE TABLE `test` (`ip` INET6);\n",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "CREATE TABLE `test` (`ip` INET6);\n",
6+
"len": 34,
7+
"last": 34,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"tokens": [
11+
{
12+
"@type": "PhpMyAdmin\\SqlParser\\Token",
13+
"token": "CREATE",
14+
"value": "CREATE",
15+
"keyword": "CREATE",
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": 6
28+
},
29+
{
30+
"@type": "PhpMyAdmin\\SqlParser\\Token",
31+
"token": "TABLE",
32+
"value": "TABLE",
33+
"keyword": "TABLE",
34+
"type": 1,
35+
"flags": 3,
36+
"position": 7
37+
},
38+
{
39+
"@type": "PhpMyAdmin\\SqlParser\\Token",
40+
"token": " ",
41+
"value": " ",
42+
"keyword": null,
43+
"type": 3,
44+
"flags": 0,
45+
"position": 12
46+
},
47+
{
48+
"@type": "PhpMyAdmin\\SqlParser\\Token",
49+
"token": "`test`",
50+
"value": "test",
51+
"keyword": null,
52+
"type": 8,
53+
"flags": 2,
54+
"position": 13
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": "(",
68+
"value": "(",
69+
"keyword": null,
70+
"type": 2,
71+
"flags": 16,
72+
"position": 20
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": "`ip`",
77+
"value": "ip",
78+
"keyword": null,
79+
"type": 8,
80+
"flags": 2,
81+
"position": 21
82+
},
83+
{
84+
"@type": "PhpMyAdmin\\SqlParser\\Token",
85+
"token": " ",
86+
"value": " ",
87+
"keyword": null,
88+
"type": 3,
89+
"flags": 0,
90+
"position": 25
91+
},
92+
{
93+
"@type": "PhpMyAdmin\\SqlParser\\Token",
94+
"token": "INET6",
95+
"value": "INET6",
96+
"keyword": "INET6",
97+
"type": 1,
98+
"flags": 9,
99+
"position": 26
100+
},
101+
{
102+
"@type": "PhpMyAdmin\\SqlParser\\Token",
103+
"token": ")",
104+
"value": ")",
105+
"keyword": null,
106+
"type": 2,
107+
"flags": 16,
108+
"position": 31
109+
},
110+
{
111+
"@type": "PhpMyAdmin\\SqlParser\\Token",
112+
"token": ";",
113+
"value": ";",
114+
"keyword": null,
115+
"type": 9,
116+
"flags": 0,
117+
"position": 32
118+
},
119+
{
120+
"@type": "PhpMyAdmin\\SqlParser\\Token",
121+
"token": "\n",
122+
"value": " ",
123+
"keyword": null,
124+
"type": 3,
125+
"flags": 0,
126+
"position": 33
127+
},
128+
{
129+
"@type": "PhpMyAdmin\\SqlParser\\Token",
130+
"token": null,
131+
"value": null,
132+
"keyword": null,
133+
"type": 9,
134+
"flags": 0,
135+
"position": null
136+
}
137+
],
138+
"count": 14,
139+
"idx": 14
140+
},
141+
"delimiter": ";",
142+
"delimiterLen": 1,
143+
"strict": false,
144+
"errors": []
145+
},
146+
"parser": {
147+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
148+
"list": {
149+
"@type": "@1"
150+
},
151+
"statements": [
152+
{
153+
"@type": "PhpMyAdmin\\SqlParser\\Statements\\CreateStatement",
154+
"name": {
155+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
156+
"database": null,
157+
"table": "test",
158+
"column": null,
159+
"expr": "`test`",
160+
"alias": null,
161+
"function": null,
162+
"subquery": null
163+
},
164+
"entityOptions": {
165+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
166+
"options": []
167+
},
168+
"fields": [
169+
{
170+
"@type": "PhpMyAdmin\\SqlParser\\Components\\CreateDefinition",
171+
"name": "ip",
172+
"isConstraint": null,
173+
"type": {
174+
"@type": "PhpMyAdmin\\SqlParser\\Components\\DataType",
175+
"name": "INET6",
176+
"parameters": [],
177+
"options": {
178+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
179+
"options": []
180+
}
181+
},
182+
"key": null,
183+
"references": null,
184+
"options": {
185+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
186+
"options": []
187+
}
188+
}
189+
],
190+
"with": null,
191+
"select": null,
192+
"like": null,
193+
"partitionBy": null,
194+
"partitionsNum": null,
195+
"subpartitionBy": null,
196+
"subpartitionsNum": null,
197+
"partitions": null,
198+
"table": null,
199+
"return": null,
200+
"parameters": null,
201+
"body": [],
202+
"options": {
203+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
204+
"options": {
205+
"6": "TABLE"
206+
}
207+
},
208+
"first": 0,
209+
"last": 11
210+
}
211+
],
212+
"brackets": 0,
213+
"strict": false,
214+
"errors": []
215+
},
216+
"errors": {
217+
"lexer": [],
218+
"parser": []
219+
}
220+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CREATE TABLE `test` (`ip` INET4);

0 commit comments

Comments
 (0)