Skip to content

Commit 68b5088

Browse files
committed
Merge branch '5.11.x'
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
2 parents 25ca219 + f40c620 commit 68b5088

33 files changed

+730
-78
lines changed

src/Parsers/AlterOperations.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ final class AlterOperations implements Parseable
136136
2,
137137
'var',
138138
],
139+
'UNIQUE' => 2,
140+
'UNIQUE KEY' => 2,
139141

140142
'CHARACTER SET' => 3,
141143
'TO' => [

tests/Parser/AlterStatementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public static function alterProvider(): array
4646
['parser/parseAlterTableCoalescePartition'],
4747
['parser/parseAlterTableAddColumnWithCheck'],
4848
['parser/parseAlterTableAddSpatialIndex1'],
49+
['parser/parseAlterTableAddUniqueKey1'],
50+
['parser/parseAlterTableAddUniqueKey2'],
4951
['parser/parseAlterTableDropAddIndex1'],
5052
['parser/parseAlterTableDropColumn1'],
5153
['parser/parseAlterTableModifyColumn'],

tests/data/bugs/gh496.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@
485485
"rightOperand": "i.id"
486486
}
487487
],
488-
"using": null
488+
"using": null,
489+
"indexHints": []
489490
}
490491
],
491492
"union": [],

tests/data/bugs/gh498.out

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@
458458
"rightOperand": "uno.id"
459459
}
460460
],
461-
"using": null
461+
"using": null,
462+
"indexHints": []
462463
}
463464
],
464465
"union": [],

tests/data/parser/parseAlter14.out

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -385,24 +385,22 @@
385385
"options": {
386386
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
387387
"options": {
388-
"1": "ADD"
388+
"1": "ADD",
389+
"2": "UNIQUE KEY"
389390
}
390391
},
391-
"field": null,
392+
"field": {
393+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
394+
"database": null,
395+
"table": null,
396+
"column": "functional_index",
397+
"expr": "`functional_index`",
398+
"alias": null,
399+
"function": null,
400+
"subquery": null
401+
},
392402
"partitions": null,
393403
"unknown": [
394-
{
395-
"@type": "@13"
396-
},
397-
{
398-
"@type": "@14"
399-
},
400-
{
401-
"@type": "@15"
402-
},
403-
{
404-
"@type": "@16"
405-
},
406404
{
407405
"@type": "@17"
408406
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE testtable ADD UNIQUE KEY name_of_the_unique_constraint (`UNIQUE_COLUMN`);
Lines changed: 300 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,300 @@
1+
{
2+
"query": "ALTER TABLE testtable ADD UNIQUE KEY name_of_the_unique_constraint (`UNIQUE_COLUMN`);\n",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"strict": false,
6+
"errors": [],
7+
"str": "ALTER TABLE testtable ADD UNIQUE KEY name_of_the_unique_constraint (`UNIQUE_COLUMN`);\n",
8+
"len": 86,
9+
"last": 86,
10+
"list": {
11+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
12+
"count": 18,
13+
"idx": 18,
14+
"tokens": [
15+
{
16+
"@type": "PhpMyAdmin\\SqlParser\\Token",
17+
"token": "ALTER",
18+
"value": "ALTER",
19+
"keyword": "ALTER",
20+
"type": {
21+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
22+
"name": "Keyword",
23+
"value": 1
24+
},
25+
"flags": 3,
26+
"position": 0
27+
},
28+
{
29+
"@type": "PhpMyAdmin\\SqlParser\\Token",
30+
"token": " ",
31+
"value": " ",
32+
"keyword": null,
33+
"type": {
34+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
35+
"name": "Whitespace",
36+
"value": 3
37+
},
38+
"flags": 0,
39+
"position": 5
40+
},
41+
{
42+
"@type": "PhpMyAdmin\\SqlParser\\Token",
43+
"token": "TABLE",
44+
"value": "TABLE",
45+
"keyword": "TABLE",
46+
"type": {
47+
"@type": "@3"
48+
},
49+
"flags": 3,
50+
"position": 6
51+
},
52+
{
53+
"@type": "PhpMyAdmin\\SqlParser\\Token",
54+
"token": " ",
55+
"value": " ",
56+
"keyword": null,
57+
"type": {
58+
"@type": "@5"
59+
},
60+
"flags": 0,
61+
"position": 11
62+
},
63+
{
64+
"@type": "PhpMyAdmin\\SqlParser\\Token",
65+
"token": "testtable",
66+
"value": "testtable",
67+
"keyword": null,
68+
"type": {
69+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
70+
"name": "None",
71+
"value": 0
72+
},
73+
"flags": 0,
74+
"position": 12
75+
},
76+
{
77+
"@type": "PhpMyAdmin\\SqlParser\\Token",
78+
"token": " ",
79+
"value": " ",
80+
"keyword": null,
81+
"type": {
82+
"@type": "@5"
83+
},
84+
"flags": 0,
85+
"position": 21
86+
},
87+
{
88+
"@type": "PhpMyAdmin\\SqlParser\\Token",
89+
"token": "ADD",
90+
"value": "ADD",
91+
"keyword": "ADD",
92+
"type": {
93+
"@type": "@3"
94+
},
95+
"flags": 3,
96+
"position": 22
97+
},
98+
{
99+
"@type": "PhpMyAdmin\\SqlParser\\Token",
100+
"token": " ",
101+
"value": " ",
102+
"keyword": null,
103+
"type": {
104+
"@type": "@5"
105+
},
106+
"flags": 0,
107+
"position": 25
108+
},
109+
{
110+
"@type": "PhpMyAdmin\\SqlParser\\Token",
111+
"token": "UNIQUE KEY",
112+
"value": "UNIQUE KEY",
113+
"keyword": "UNIQUE KEY",
114+
"type": {
115+
"@type": "@3"
116+
},
117+
"flags": 23,
118+
"position": 26
119+
},
120+
{
121+
"@type": "PhpMyAdmin\\SqlParser\\Token",
122+
"token": " ",
123+
"value": " ",
124+
"keyword": null,
125+
"type": {
126+
"@type": "@5"
127+
},
128+
"flags": 0,
129+
"position": 36
130+
},
131+
{
132+
"@type": "PhpMyAdmin\\SqlParser\\Token",
133+
"token": "name_of_the_unique_constraint",
134+
"value": "name_of_the_unique_constraint",
135+
"keyword": null,
136+
"type": {
137+
"@type": "@9"
138+
},
139+
"flags": 0,
140+
"position": 37
141+
},
142+
{
143+
"@type": "PhpMyAdmin\\SqlParser\\Token",
144+
"token": " ",
145+
"value": " ",
146+
"keyword": null,
147+
"type": {
148+
"@type": "@5"
149+
},
150+
"flags": 0,
151+
"position": 66
152+
},
153+
{
154+
"@type": "PhpMyAdmin\\SqlParser\\Token",
155+
"token": "(",
156+
"value": "(",
157+
"keyword": null,
158+
"type": {
159+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
160+
"name": "Operator",
161+
"value": 2
162+
},
163+
"flags": 16,
164+
"position": 67
165+
},
166+
{
167+
"@type": "PhpMyAdmin\\SqlParser\\Token",
168+
"token": "`UNIQUE_COLUMN`",
169+
"value": "UNIQUE_COLUMN",
170+
"keyword": null,
171+
"type": {
172+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
173+
"name": "Symbol",
174+
"value": 8
175+
},
176+
"flags": 2,
177+
"position": 68
178+
},
179+
{
180+
"@type": "PhpMyAdmin\\SqlParser\\Token",
181+
"token": ")",
182+
"value": ")",
183+
"keyword": null,
184+
"type": {
185+
"@type": "@18"
186+
},
187+
"flags": 16,
188+
"position": 83
189+
},
190+
{
191+
"@type": "PhpMyAdmin\\SqlParser\\Token",
192+
"token": ";",
193+
"value": ";",
194+
"keyword": null,
195+
"type": {
196+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
197+
"name": "Delimiter",
198+
"value": 9
199+
},
200+
"flags": 0,
201+
"position": 84
202+
},
203+
{
204+
"@type": "PhpMyAdmin\\SqlParser\\Token",
205+
"token": "\n",
206+
"value": " ",
207+
"keyword": null,
208+
"type": {
209+
"@type": "@5"
210+
},
211+
"flags": 0,
212+
"position": 85
213+
},
214+
{
215+
"@type": "PhpMyAdmin\\SqlParser\\Token",
216+
"token": "",
217+
"value": "",
218+
"keyword": null,
219+
"type": {
220+
"@type": "@23"
221+
},
222+
"flags": 0,
223+
"position": null
224+
}
225+
]
226+
},
227+
"delimiter": ";",
228+
"delimiterLen": 1
229+
},
230+
"parser": {
231+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
232+
"strict": false,
233+
"errors": [],
234+
"list": {
235+
"@type": "@1"
236+
},
237+
"statements": [
238+
{
239+
"@type": "PhpMyAdmin\\SqlParser\\Statements\\AlterStatement",
240+
"table": {
241+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
242+
"database": null,
243+
"table": "testtable",
244+
"column": null,
245+
"expr": "testtable",
246+
"alias": null,
247+
"function": null,
248+
"subquery": null
249+
},
250+
"altered": [
251+
{
252+
"@type": "PhpMyAdmin\\SqlParser\\Components\\AlterOperation",
253+
"options": {
254+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
255+
"options": {
256+
"1": "ADD",
257+
"2": "UNIQUE KEY"
258+
}
259+
},
260+
"field": {
261+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
262+
"database": null,
263+
"table": null,
264+
"column": "name_of_the_unique_constraint",
265+
"expr": "name_of_the_unique_constraint",
266+
"alias": null,
267+
"function": null,
268+
"subquery": null
269+
},
270+
"partitions": null,
271+
"unknown": [
272+
{
273+
"@type": "@17"
274+
},
275+
{
276+
"@type": "@19"
277+
},
278+
{
279+
"@type": "@21"
280+
}
281+
]
282+
}
283+
],
284+
"options": {
285+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
286+
"options": {
287+
"3": "TABLE"
288+
}
289+
},
290+
"first": 0,
291+
"last": 15
292+
}
293+
],
294+
"brackets": 0
295+
},
296+
"errors": {
297+
"lexer": [],
298+
"parser": []
299+
}
300+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE testtable ADD UNIQUE name_of_the_unique_constraint (`UNIQUE_COLUMN`);

0 commit comments

Comments
 (0)