Skip to content

Commit

Permalink
Merge branch '5.8.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Aug 12, 2023
2 parents 58e2f30 + e93d945 commit d70e65d
Show file tree
Hide file tree
Showing 5 changed files with 372 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fix `ALTER TABLE … MODIFY … ENUM('<reserved_keyword>')` is being wrongly parsed (#234)
- Fix `ALTER TABLE … MODIFY … ENUM('<reserved_keyword>')` is being wrongly parsed (#478)
- Fix MariaDB window function with alias gives bad linting errors (#283)
- Fix unrecognized keyword `COLLATE` in `WHERE` clauses (#491)

## [5.8.0] - 2023-06-05

Expand Down
1 change: 1 addition & 0 deletions src/Components/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ final class Condition implements Component
'ALL' => 1,
'AND' => 1,
'BETWEEN' => 1,
'COLLATE' => 1,
'EXISTS' => 1,
'IF' => 1,
'IN' => 1,
Expand Down
1 change: 1 addition & 0 deletions tests/Parser/SelectStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public static function selectProvider(): array
['parser/parseSelectUnion'],
['parser/parseSelectUnion2'],
['parser/parseSelectWhere'],
['parser/parseSelectWhereCollate'],
['parser/parseSelectIndexHint1'],
['parser/parseSelectIndexHint2'],
['parser/parseSelectOrderByIsNull'],
Expand Down
1 change: 1 addition & 0 deletions tests/data/parser/parseSelectWhereCollate.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SELECT 1 FROM my_table WHERE first_col = 'foo' AND second_col COLLATE utf8_bin = 'bar';
368 changes: 368 additions & 0 deletions tests/data/parser/parseSelectWhereCollate.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,368 @@
{
"query": "SELECT 1 FROM my_table WHERE first_col = 'foo' AND second_col COLLATE utf8_bin = 'bar';",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"str": "SELECT 1 FROM my_table WHERE first_col = 'foo' AND second_col COLLATE utf8_bin = 'bar';",
"len": 96,
"last": 96,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "SELECT",
"value": "SELECT",
"keyword": "SELECT",
"type": 1,
"flags": 3,
"position": 0
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 6
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "1",
"value": 1,
"keyword": null,
"type": 6,
"flags": 0,
"position": 8
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 9
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "FROM",
"value": "FROM",
"keyword": "FROM",
"type": 1,
"flags": 3,
"position": 10
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 14
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "my_table",
"value": "my_table",
"keyword": null,
"type": 0,
"flags": 0,
"position": 17
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 25
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "WHERE",
"value": "WHERE",
"keyword": "WHERE",
"type": 1,
"flags": 3,
"position": 26
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 31
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "first_col",
"value": "first_col",
"keyword": null,
"type": 0,
"flags": 0,
"position": 34
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 43
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "=",
"value": "=",
"keyword": null,
"type": 2,
"flags": 2,
"position": 44
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 45
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "'foo'",
"value": "foo",
"keyword": null,
"type": 7,
"flags": 1,
"position": 46
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 51
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "AND",
"value": "AND",
"keyword": "AND",
"type": 1,
"flags": 3,
"position": 52
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 55
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "second_col",
"value": "second_col",
"keyword": null,
"type": 0,
"flags": 0,
"position": 60
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 70
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "COLLATE",
"value": "COLLATE",
"keyword": "COLLATE",
"type": 1,
"flags": 3,
"position": 71
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 78
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "utf8_bin",
"value": "utf8_bin",
"keyword": null,
"type": 0,
"flags": 0,
"position": 79
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 87
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "=",
"value": "=",
"keyword": null,
"type": 2,
"flags": 2,
"position": 88
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 89
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "'bar'",
"value": "bar",
"keyword": null,
"type": 7,
"flags": 1,
"position": 90
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ";",
"value": ";",
"keyword": null,
"type": 9,
"flags": 0,
"position": 95
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 29,
"idx": 29
},
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": {
"@type": "PhpMyAdmin\\SqlParser\\Parser",
"list": {
"@type": "@1"
},
"statements": [
{
"@type": "PhpMyAdmin\\SqlParser\\Statements\\SelectStatement",
"expr": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
"database": null,
"table": null,
"column": null,
"expr": "1",
"alias": null,
"function": null,
"subquery": null
}
],
"from": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
"database": null,
"table": "my_table",
"column": null,
"expr": "my_table",
"alias": null,
"function": null,
"subquery": null
}
],
"indexHints": null,
"partition": null,
"where": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [
"first_col",
"foo"
],
"isOperator": false,
"expr": "first_col = 'foo'"
},
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [],
"isOperator": true,
"expr": "AND"
},
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [
"second_col",
"utf8_bin",
"bar"
],
"isOperator": false,
"expr": "second_col COLLATE utf8_bin = 'bar'"
}
],
"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": 26
}
],
"brackets": 0,
"strict": false,
"errors": []
},
"errors": {
"lexer": [],
"parser": []
}
}

0 comments on commit d70e65d

Please sign in to comment.