Skip to content

Commit f7b6920

Browse files
committed
Merge branch '5.9.x'
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2 parents a870bca + 24d734a commit f7b6920

File tree

15 files changed

+1871
-3
lines changed

15 files changed

+1871
-3
lines changed

‎src/Components/Condition.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
194194
&& (($token->type !== TokenType::Keyword)
195195
|| ($token->flags & Token::FLAG_KEYWORD_RESERVED))
196196
&& ($token->type !== TokenType::String)
197-
&& ($token->type !== TokenType::Symbol)
197+
&& ($token->type !== TokenType::Symbol || ($token->flags & Token::FLAG_SYMBOL_PARAMETER))
198198
) {
199199
continue;
200200
}

‎src/Components/Expression.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
360360
|| ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED))))
361361
&& (($prev[1]->type === TokenType::String)
362362
|| ($prev[1]->type === TokenType::Symbol
363-
&& ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE))
363+
&& ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE)
364+
&& ! ($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER))
364365
|| ($prev[1]->type === TokenType::None
365366
&& $prev[1]->token !== 'OVER'))
366367
) {

‎src/Lexer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ public function parseSymbol(): Token|null
930930
if ($str === null) {
931931
$str = $this->parseUnknown();
932932

933-
if ($str === null) {
933+
if ($str === null && ! ($flags & Token::FLAG_SYMBOL_PARAMETER)) {
934934
$this->error('Variable name was expected.', $this->str[$this->last], $this->last);
935935
}
936936
}

‎tests/Misc/BugsTest.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ public static function bugProvider(): array
2828
['bugs/gh9'],
2929
['bugs/gh14'],
3030
['bugs/gh16'],
31+
['bugs/gh202'],
3132
['bugs/gh234'],
3233
['bugs/gh317'],
34+
['bugs/gh412'],
3335
['bugs/gh478'],
36+
['bugs/gh492'],
37+
['bugs/gh499'],
3438
['bugs/gh508'],
3539
['bugs/gh511'],
3640
['bugs/pma11800'],

‎tests/Misc/ParameterTest.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static function parameterProvider(): array
2222
{
2323
return [
2424
['misc/parseParameter'],
25+
['misc/parseParameter2'],
2526
];
2627
}
2728
}

‎tests/data/bugs/gh202.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
update tbl_customer t set t.`description`=:yp where t.id=1;

‎tests/data/bugs/gh202.out‎

Lines changed: 344 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
{
2+
"query": "update tbl_customer t set t.`description`=:yp where t.id=1;",
3+
"lexer": {
4+
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
5+
"str": "update tbl_customer t set t.`description`=:yp where t.id=1;",
6+
"len": 59,
7+
"last": 59,
8+
"list": {
9+
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
10+
"count": 23,
11+
"idx": 23,
12+
"tokens": [
13+
{
14+
"@type": "PhpMyAdmin\\SqlParser\\Token",
15+
"token": "update",
16+
"value": "UPDATE",
17+
"keyword": "UPDATE",
18+
"type": {
19+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
20+
"name": "Keyword",
21+
"value": 1
22+
},
23+
"flags": 3,
24+
"position": 0
25+
},
26+
{
27+
"@type": "PhpMyAdmin\\SqlParser\\Token",
28+
"token": " ",
29+
"value": " ",
30+
"keyword": null,
31+
"type": {
32+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
33+
"name": "Whitespace",
34+
"value": 3
35+
},
36+
"flags": 0,
37+
"position": 6
38+
},
39+
{
40+
"@type": "PhpMyAdmin\\SqlParser\\Token",
41+
"token": "tbl_customer",
42+
"value": "tbl_customer",
43+
"keyword": null,
44+
"type": {
45+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
46+
"name": "None",
47+
"value": 0
48+
},
49+
"flags": 0,
50+
"position": 7
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": 19
62+
},
63+
{
64+
"@type": "PhpMyAdmin\\SqlParser\\Token",
65+
"token": "t",
66+
"value": "t",
67+
"keyword": null,
68+
"type": {
69+
"@type": "@7"
70+
},
71+
"flags": 0,
72+
"position": 20
73+
},
74+
{
75+
"@type": "PhpMyAdmin\\SqlParser\\Token",
76+
"token": " ",
77+
"value": " ",
78+
"keyword": null,
79+
"type": {
80+
"@type": "@5"
81+
},
82+
"flags": 0,
83+
"position": 21
84+
},
85+
{
86+
"@type": "PhpMyAdmin\\SqlParser\\Token",
87+
"token": "set",
88+
"value": "SET",
89+
"keyword": "SET",
90+
"type": {
91+
"@type": "@3"
92+
},
93+
"flags": 11,
94+
"position": 22
95+
},
96+
{
97+
"@type": "PhpMyAdmin\\SqlParser\\Token",
98+
"token": " ",
99+
"value": " ",
100+
"keyword": null,
101+
"type": {
102+
"@type": "@5"
103+
},
104+
"flags": 0,
105+
"position": 25
106+
},
107+
{
108+
"@type": "PhpMyAdmin\\SqlParser\\Token",
109+
"token": "t",
110+
"value": "t",
111+
"keyword": null,
112+
"type": {
113+
"@type": "@7"
114+
},
115+
"flags": 0,
116+
"position": 26
117+
},
118+
{
119+
"@type": "PhpMyAdmin\\SqlParser\\Token",
120+
"token": ".",
121+
"value": ".",
122+
"keyword": null,
123+
"type": {
124+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
125+
"name": "Operator",
126+
"value": 2
127+
},
128+
"flags": 16,
129+
"position": 27
130+
},
131+
{
132+
"@type": "PhpMyAdmin\\SqlParser\\Token",
133+
"token": "`description`",
134+
"value": "description",
135+
"keyword": null,
136+
"type": {
137+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
138+
"name": "Symbol",
139+
"value": 8
140+
},
141+
"flags": 2,
142+
"position": 28
143+
},
144+
{
145+
"@type": "PhpMyAdmin\\SqlParser\\Token",
146+
"token": "=",
147+
"value": "=",
148+
"keyword": null,
149+
"type": {
150+
"@type": "@15"
151+
},
152+
"flags": 2,
153+
"position": 41
154+
},
155+
{
156+
"@type": "PhpMyAdmin\\SqlParser\\Token",
157+
"token": ":yp",
158+
"value": "yp",
159+
"keyword": null,
160+
"type": {
161+
"@type": "@17"
162+
},
163+
"flags": 16,
164+
"position": 42
165+
},
166+
{
167+
"@type": "PhpMyAdmin\\SqlParser\\Token",
168+
"token": " ",
169+
"value": " ",
170+
"keyword": null,
171+
"type": {
172+
"@type": "@5"
173+
},
174+
"flags": 0,
175+
"position": 45
176+
},
177+
{
178+
"@type": "PhpMyAdmin\\SqlParser\\Token",
179+
"token": "where",
180+
"value": "WHERE",
181+
"keyword": "WHERE",
182+
"type": {
183+
"@type": "@3"
184+
},
185+
"flags": 3,
186+
"position": 46
187+
},
188+
{
189+
"@type": "PhpMyAdmin\\SqlParser\\Token",
190+
"token": " ",
191+
"value": " ",
192+
"keyword": null,
193+
"type": {
194+
"@type": "@5"
195+
},
196+
"flags": 0,
197+
"position": 51
198+
},
199+
{
200+
"@type": "PhpMyAdmin\\SqlParser\\Token",
201+
"token": "t",
202+
"value": "t",
203+
"keyword": null,
204+
"type": {
205+
"@type": "@7"
206+
},
207+
"flags": 0,
208+
"position": 52
209+
},
210+
{
211+
"@type": "PhpMyAdmin\\SqlParser\\Token",
212+
"token": ".",
213+
"value": ".",
214+
"keyword": null,
215+
"type": {
216+
"@type": "@15"
217+
},
218+
"flags": 16,
219+
"position": 53
220+
},
221+
{
222+
"@type": "PhpMyAdmin\\SqlParser\\Token",
223+
"token": "id",
224+
"value": "id",
225+
"keyword": null,
226+
"type": {
227+
"@type": "@7"
228+
},
229+
"flags": 0,
230+
"position": 54
231+
},
232+
{
233+
"@type": "PhpMyAdmin\\SqlParser\\Token",
234+
"token": "=",
235+
"value": "=",
236+
"keyword": null,
237+
"type": {
238+
"@type": "@15"
239+
},
240+
"flags": 2,
241+
"position": 56
242+
},
243+
{
244+
"@type": "PhpMyAdmin\\SqlParser\\Token",
245+
"token": "1",
246+
"value": 1,
247+
"keyword": null,
248+
"type": {
249+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
250+
"name": "Number",
251+
"value": 6
252+
},
253+
"flags": 0,
254+
"position": 57
255+
},
256+
{
257+
"@type": "PhpMyAdmin\\SqlParser\\Token",
258+
"token": ";",
259+
"value": ";",
260+
"keyword": null,
261+
"type": {
262+
"@type": "PhpMyAdmin\\SqlParser\\TokenType",
263+
"name": "Delimiter",
264+
"value": 9
265+
},
266+
"flags": 0,
267+
"position": 58
268+
},
269+
{
270+
"@type": "PhpMyAdmin\\SqlParser\\Token",
271+
"token": null,
272+
"value": null,
273+
"keyword": null,
274+
"type": {
275+
"@type": "@30"
276+
},
277+
"flags": 0,
278+
"position": null
279+
}
280+
]
281+
},
282+
"delimiter": ";",
283+
"delimiterLen": 1,
284+
"strict": false,
285+
"errors": []
286+
},
287+
"parser": {
288+
"@type": "PhpMyAdmin\\SqlParser\\Parser",
289+
"list": {
290+
"@type": "@1"
291+
},
292+
"statements": [
293+
{
294+
"@type": "PhpMyAdmin\\SqlParser\\Statements\\UpdateStatement",
295+
"tables": [
296+
{
297+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
298+
"database": null,
299+
"table": "tbl_customer",
300+
"column": null,
301+
"expr": "tbl_customer",
302+
"alias": "t",
303+
"function": null,
304+
"subquery": null
305+
}
306+
],
307+
"set": [
308+
{
309+
"@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation",
310+
"column": "t.`description`",
311+
"value": ":yp"
312+
}
313+
],
314+
"where": [
315+
{
316+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
317+
"identifiers": [
318+
"t",
319+
"id"
320+
],
321+
"isOperator": false,
322+
"expr": "t.id=1"
323+
}
324+
],
325+
"order": null,
326+
"limit": null,
327+
"join": null,
328+
"options": {
329+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
330+
"options": []
331+
},
332+
"first": 0,
333+
"last": 20
334+
}
335+
],
336+
"brackets": 0,
337+
"strict": false,
338+
"errors": []
339+
},
340+
"errors": {
341+
"lexer": [],
342+
"parser": []
343+
}
344+
}

0 commit comments

Comments
 (0)