Skip to content

Commit

Permalink
Ref #447 - Add test cases for TABLE statements
Browse files Browse the repository at this point in the history
Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 9, 2023
1 parent 876af83 commit cddd0f1
Show file tree
Hide file tree
Showing 6 changed files with 368 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/Parser/ExplainStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function explainProvider(): array
['parser/parseExplain11'],
['parser/parseExplain12'],
['parser/parseExplain13'],
['parser/parseExplain14'],
['parser/parseExplainErr'],
['parser/parseExplainErr1'],
['parser/parseExplainErr2'],
Expand Down
1 change: 1 addition & 0 deletions tests/Parser/SelectStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function selectProvider(): array
['parser/parseSelectGroupBy'],
['parser/parseSelectGroupByErr'],
['parser/parseSelectGroupByWithComments'],
['parser/parseTable1'],
];
}
}
1 change: 1 addition & 0 deletions tests/data/parser/parseExplain14.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DESC TABLE `fo` ORDER BY `fo`.`uuid` ASC;
205 changes: 205 additions & 0 deletions tests/data/parser/parseExplain14.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
{
"query": "DESC TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"str": "DESC TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
"len": 41,
"last": 41,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "DESC",
"value": "DESC",
"keyword": "DESC",
"type": 1,
"flags": 3,
"position": 0
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 4
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "TABLE",
"value": "TABLE",
"keyword": "TABLE",
"type": 1,
"flags": 3,
"position": 5
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 10
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "`fo`",
"value": "fo",
"keyword": null,
"type": 8,
"flags": 2,
"position": 11
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 15
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "ORDER BY",
"value": "ORDER BY",
"keyword": "ORDER BY",
"type": 1,
"flags": 7,
"position": 16
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 24
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "`fo`",
"value": "fo",
"keyword": null,
"type": 8,
"flags": 2,
"position": 25
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ".",
"value": ".",
"keyword": null,
"type": 2,
"flags": 16,
"position": 29
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "`uuid`",
"value": "uuid",
"keyword": null,
"type": 8,
"flags": 2,
"position": 30
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 36
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "ASC",
"value": "ASC",
"keyword": "ASC",
"type": 1,
"flags": 3,
"position": 37
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ";",
"value": ";",
"keyword": null,
"type": 9,
"flags": 0,
"position": 40
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 15,
"idx": 15
},
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": {
"@type": "PhpMyAdmin\\SqlParser\\Parser",
"list": {
"@type": "@1"
},
"statements": [
{
"@type": "PhpMyAdmin\\SqlParser\\Statements\\ExplainStatement",
"bodyParser": null,
"statementAlias": "DESC",
"connectionId": null,
"explainedTable": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 2
}
],
"brackets": 0,
"strict": false,
"errors": []
},
"errors": {
"lexer": [],
"parser": [
[
"Unexpected token.",
{
"@type": "@4"
},
0
],
[
"Unexpected beginning of statement.",
{
"@type": "@6"
},
0
],
[
"Unrecognized statement type.",
{
"@type": "@8"
},
0
]
]
}
}
1 change: 1 addition & 0 deletions tests/data/parser/parseTable1.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TABLE `fo` ORDER BY `fo`.`uuid` ASC;
159 changes: 159 additions & 0 deletions tests/data/parser/parseTable1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
{
"query": "TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"str": "TABLE `fo` ORDER BY `fo`.`uuid` ASC;",
"len": 36,
"last": 36,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "TABLE",
"value": "TABLE",
"keyword": "TABLE",
"type": 1,
"flags": 3,
"position": 0
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 5
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "`fo`",
"value": "fo",
"keyword": null,
"type": 8,
"flags": 2,
"position": 6
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 10
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "ORDER BY",
"value": "ORDER BY",
"keyword": "ORDER BY",
"type": 1,
"flags": 7,
"position": 11
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 19
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "`fo`",
"value": "fo",
"keyword": null,
"type": 8,
"flags": 2,
"position": 20
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ".",
"value": ".",
"keyword": null,
"type": 2,
"flags": 16,
"position": 24
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "`uuid`",
"value": "uuid",
"keyword": null,
"type": 8,
"flags": 2,
"position": 25
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 31
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "ASC",
"value": "ASC",
"keyword": "ASC",
"type": 1,
"flags": 3,
"position": 32
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ";",
"value": ";",
"keyword": null,
"type": 9,
"flags": 0,
"position": 35
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 13,
"idx": 13
},
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": {
"@type": "PhpMyAdmin\\SqlParser\\Parser",
"list": {
"@type": "@1"
},
"statements": [],
"brackets": 0,
"strict": false,
"errors": []
},
"errors": {
"lexer": [],
"parser": [
[
"Unrecognized statement type.",
{
"@type": "@2"
},
0
]
]
}
}

0 comments on commit cddd0f1

Please sign in to comment.