Skip to content

Commit

Permalink
Merge pull request #547 from MauricioFauth/fix-index-hint-field-name
Browse files Browse the repository at this point in the history
Fix field name for when parsing index hints
  • Loading branch information
MauricioFauth committed Jan 26, 2024
2 parents ac1004c + 1b0058d commit 8857557
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 112 deletions.
2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Expand Up @@ -456,7 +456,7 @@ parameters:
path: src/Statement.php

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

Expand Down
6 changes: 3 additions & 3 deletions src/Parser.php
Expand Up @@ -192,7 +192,7 @@ class Parser
],
'FORCE' => [
'class' => Parsers\IndexHints::class,
'field' => 'index_hints',
'field' => 'indexHints',
],
'FROM' => [
'class' => Parsers\ExpressionArray::class,
Expand All @@ -209,7 +209,7 @@ class Parser
],
'IGNORE' => [
'class' => Parsers\IndexHints::class,
'field' => 'index_hints',
'field' => 'indexHints',
],
'INTO' => [
'class' => Parsers\IntoKeywords::class,
Expand Down Expand Up @@ -331,7 +331,7 @@ class Parser
],
'USE' => [
'class' => Parsers\IndexHints::class,
'field' => 'index_hints',
'field' => 'indexHints',
],
'VALUE' => [
'class' => Parsers\Array2d::class,
Expand Down
59 changes: 29 additions & 30 deletions tests/data/parser/parseSelectIndexHint1.out
Expand Up @@ -503,35 +503,7 @@
"subquery": null
}
],
"indexHints": null,
"partition": null,
"where": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [
"city_id"
],
"isOperator": false,
"expr": "city_id<0"
}
],
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 37,
"index_hints": [
"indexHints": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
"type": "FORCE",
Expand Down Expand Up @@ -568,7 +540,34 @@
}
]
}
]
],
"partition": null,
"where": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [
"city_id"
],
"isOperator": false,
"expr": "city_id<0"
}
],
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 37
}
],
"brackets": 0
Expand Down
59 changes: 29 additions & 30 deletions tests/data/parser/parseSelectIndexHint2.out
Expand Up @@ -492,35 +492,7 @@
"subquery": null
}
],
"indexHints": null,
"partition": null,
"where": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [
"city_id"
],
"isOperator": false,
"expr": "city_id<0"
}
],
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 37,
"index_hints": [
"indexHints": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
"type": "USE",
Expand Down Expand Up @@ -557,7 +529,34 @@
}
]
}
]
],
"partition": null,
"where": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [
"city_id"
],
"isOperator": false,
"expr": "city_id<0"
}
],
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 37
}
],
"brackets": 0
Expand Down
41 changes: 20 additions & 21 deletions tests/data/parser/parseSelectIndexHintErr1.out
Expand Up @@ -248,26 +248,7 @@
"subquery": null
}
],
"indexHints": null,
"partition": null,
"where": null,
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 14,
"index_hints": [
"indexHints": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
"type": "FORCE",
Expand All @@ -286,7 +267,25 @@
}
]
}
]
],
"partition": null,
"where": null,
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 14
}
],
"brackets": 0
Expand Down
5 changes: 2 additions & 3 deletions tests/data/parser/parseSelectIndexHintErr2.out
Expand Up @@ -248,7 +248,7 @@
"subquery": null
}
],
"indexHints": null,
"indexHints": [],
"partition": null,
"where": null,
"group": null,
Expand All @@ -266,8 +266,7 @@
"options": []
},
"first": 0,
"last": 14,
"index_hints": []
"last": 14
}
],
"brackets": 0
Expand Down
5 changes: 2 additions & 3 deletions tests/data/parser/parseSelectIndexHintErr3.out
Expand Up @@ -292,7 +292,7 @@
"subquery": null
}
],
"indexHints": null,
"indexHints": [],
"partition": null,
"where": null,
"group": null,
Expand All @@ -310,8 +310,7 @@
"options": []
},
"first": 0,
"last": 18,
"index_hints": []
"last": 18
}
],
"brackets": 0
Expand Down
41 changes: 20 additions & 21 deletions tests/data/parser/parseSelectIndexHintErr4.out
Expand Up @@ -292,26 +292,7 @@
"subquery": null
}
],
"indexHints": null,
"partition": null,
"where": null,
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 18,
"index_hints": [
"indexHints": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\IndexHint",
"type": "FORCE",
Expand All @@ -330,7 +311,25 @@
}
]
}
]
],
"partition": null,
"where": null,
"group": null,
"groupOptions": null,
"having": null,
"order": null,
"limit": null,
"procedure": null,
"into": null,
"join": null,
"union": [],
"endOptions": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 18
}
],
"brackets": 0
Expand Down

0 comments on commit 8857557

Please sign in to comment.