Skip to content

Commit 8857557

Browse files
Merge pull request #547 from MauricioFauth/fix-index-hint-field-name
Fix field name for when parsing index hints
2 parents ac1004c + 1b0058d commit 8857557

8 files changed

Lines changed: 106 additions & 112 deletions

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ parameters:
456456
path: src/Statement.php
457457

458458
-
459-
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$index_hints\\.$#"
459+
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$indexHints\\.$#"
460460
count: 1
461461
path: src/Statement.php
462462

src/Parser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ class Parser
192192
],
193193
'FORCE' => [
194194
'class' => Parsers\IndexHints::class,
195-
'field' => 'index_hints',
195+
'field' => 'indexHints',
196196
],
197197
'FROM' => [
198198
'class' => Parsers\ExpressionArray::class,
@@ -209,7 +209,7 @@ class Parser
209209
],
210210
'IGNORE' => [
211211
'class' => Parsers\IndexHints::class,
212-
'field' => 'index_hints',
212+
'field' => 'indexHints',
213213
],
214214
'INTO' => [
215215
'class' => Parsers\IntoKeywords::class,
@@ -331,7 +331,7 @@ class Parser
331331
],
332332
'USE' => [
333333
'class' => Parsers\IndexHints::class,
334-
'field' => 'index_hints',
334+
'field' => 'indexHints',
335335
],
336336
'VALUE' => [
337337
'class' => Parsers\Array2d::class,

tests/data/parser/parseSelectIndexHint1.out

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -503,35 +503,7 @@
503503
"subquery": null
504504
}
505505
],
506-
"indexHints": null,
507-
"partition": null,
508-
"where": [
509-
{
510-
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
511-
"identifiers": [
512-
"city_id"
513-
],
514-
"isOperator": false,
515-
"expr": "city_id<0"
516-
}
517-
],
518-
"group": null,
519-
"groupOptions": null,
520-
"having": null,
521-
"order": null,
522-
"limit": null,
523-
"procedure": null,
524-
"into": null,
525-
"join": null,
526-
"union": [],
527-
"endOptions": null,
528-
"options": {
529-
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
530-
"options": []
531-
},
532-
"first": 0,
533-
"last": 37,
534-
"index_hints": [
506+
"indexHints": [
535507
{
536508
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
537509
"type": "FORCE",
@@ -568,7 +540,34 @@
568540
}
569541
]
570542
}
571-
]
543+
],
544+
"partition": null,
545+
"where": [
546+
{
547+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
548+
"identifiers": [
549+
"city_id"
550+
],
551+
"isOperator": false,
552+
"expr": "city_id<0"
553+
}
554+
],
555+
"group": null,
556+
"groupOptions": null,
557+
"having": null,
558+
"order": null,
559+
"limit": null,
560+
"procedure": null,
561+
"into": null,
562+
"join": null,
563+
"union": [],
564+
"endOptions": null,
565+
"options": {
566+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
567+
"options": []
568+
},
569+
"first": 0,
570+
"last": 37
572571
}
573572
],
574573
"brackets": 0

tests/data/parser/parseSelectIndexHint2.out

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -492,35 +492,7 @@
492492
"subquery": null
493493
}
494494
],
495-
"indexHints": null,
496-
"partition": null,
497-
"where": [
498-
{
499-
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
500-
"identifiers": [
501-
"city_id"
502-
],
503-
"isOperator": false,
504-
"expr": "city_id<0"
505-
}
506-
],
507-
"group": null,
508-
"groupOptions": null,
509-
"having": null,
510-
"order": null,
511-
"limit": null,
512-
"procedure": null,
513-
"into": null,
514-
"join": null,
515-
"union": [],
516-
"endOptions": null,
517-
"options": {
518-
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
519-
"options": []
520-
},
521-
"first": 0,
522-
"last": 37,
523-
"index_hints": [
495+
"indexHints": [
524496
{
525497
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
526498
"type": "USE",
@@ -557,7 +529,34 @@
557529
}
558530
]
559531
}
560-
]
532+
],
533+
"partition": null,
534+
"where": [
535+
{
536+
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
537+
"identifiers": [
538+
"city_id"
539+
],
540+
"isOperator": false,
541+
"expr": "city_id<0"
542+
}
543+
],
544+
"group": null,
545+
"groupOptions": null,
546+
"having": null,
547+
"order": null,
548+
"limit": null,
549+
"procedure": null,
550+
"into": null,
551+
"join": null,
552+
"union": [],
553+
"endOptions": null,
554+
"options": {
555+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
556+
"options": []
557+
},
558+
"first": 0,
559+
"last": 37
561560
}
562561
],
563562
"brackets": 0

tests/data/parser/parseSelectIndexHintErr1.out

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -248,26 +248,7 @@
248248
"subquery": null
249249
}
250250
],
251-
"indexHints": null,
252-
"partition": null,
253-
"where": null,
254-
"group": null,
255-
"groupOptions": null,
256-
"having": null,
257-
"order": null,
258-
"limit": null,
259-
"procedure": null,
260-
"into": null,
261-
"join": null,
262-
"union": [],
263-
"endOptions": null,
264-
"options": {
265-
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
266-
"options": []
267-
},
268-
"first": 0,
269-
"last": 14,
270-
"index_hints": [
251+
"indexHints": [
271252
{
272253
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
273254
"type": "FORCE",
@@ -286,7 +267,25 @@
286267
}
287268
]
288269
}
289-
]
270+
],
271+
"partition": null,
272+
"where": null,
273+
"group": null,
274+
"groupOptions": null,
275+
"having": null,
276+
"order": null,
277+
"limit": null,
278+
"procedure": null,
279+
"into": null,
280+
"join": null,
281+
"union": [],
282+
"endOptions": null,
283+
"options": {
284+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
285+
"options": []
286+
},
287+
"first": 0,
288+
"last": 14
290289
}
291290
],
292291
"brackets": 0

tests/data/parser/parseSelectIndexHintErr2.out

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@
248248
"subquery": null
249249
}
250250
],
251-
"indexHints": null,
251+
"indexHints": [],
252252
"partition": null,
253253
"where": null,
254254
"group": null,
@@ -266,8 +266,7 @@
266266
"options": []
267267
},
268268
"first": 0,
269-
"last": 14,
270-
"index_hints": []
269+
"last": 14
271270
}
272271
],
273272
"brackets": 0

tests/data/parser/parseSelectIndexHintErr3.out

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
"subquery": null
293293
}
294294
],
295-
"indexHints": null,
295+
"indexHints": [],
296296
"partition": null,
297297
"where": null,
298298
"group": null,
@@ -310,8 +310,7 @@
310310
"options": []
311311
},
312312
"first": 0,
313-
"last": 18,
314-
"index_hints": []
313+
"last": 18
315314
}
316315
],
317316
"brackets": 0

tests/data/parser/parseSelectIndexHintErr4.out

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -292,26 +292,7 @@
292292
"subquery": null
293293
}
294294
],
295-
"indexHints": null,
296-
"partition": null,
297-
"where": null,
298-
"group": null,
299-
"groupOptions": null,
300-
"having": null,
301-
"order": null,
302-
"limit": null,
303-
"procedure": null,
304-
"into": null,
305-
"join": null,
306-
"union": [],
307-
"endOptions": null,
308-
"options": {
309-
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
310-
"options": []
311-
},
312-
"first": 0,
313-
"last": 18,
314-
"index_hints": [
295+
"indexHints": [
315296
{
316297
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
317298
"type": "FORCE",
@@ -330,7 +311,25 @@
330311
}
331312
]
332313
}
333-
]
314+
],
315+
"partition": null,
316+
"where": null,
317+
"group": null,
318+
"groupOptions": null,
319+
"having": null,
320+
"order": null,
321+
"limit": null,
322+
"procedure": null,
323+
"into": null,
324+
"join": null,
325+
"union": [],
326+
"endOptions": null,
327+
"options": {
328+
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
329+
"options": []
330+
},
331+
"first": 0,
332+
"last": 18
334333
}
335334
],
336335
"brackets": 0

0 commit comments

Comments
 (0)