Skip to content

Commit

Permalink
add additional tests for SetStatement
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Savin <andrei.v.savin@gmail.com>
  • Loading branch information
ansavin committed May 6, 2023
1 parent 510c6d8 commit 24d9cfa
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/Parser/SetStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public function setProvider(): array
['parser/parseSetNamesError'],
['parser/parseSetError1'],
['parser/parseInsertIntoSet'],
['parser/parseSetVariable'],
['parser/parseSetGlobalVariable'],
];
}
}
1 change: 1 addition & 0 deletions tests/data/parser/parseSetGlobalVariable.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SET GLOBAL max_connections = 1
144 changes: 144 additions & 0 deletions tests/data/parser/parseSetGlobalVariable.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
{
"query": "SET GLOBAL max_connections = 1",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"str": "SET GLOBAL max_connections = 1",
"len": 30,
"last": 30,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "SET",
"value": "SET",
"keyword": "SET",
"type": 1,
"flags": 11,
"position": 0
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 3
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "GLOBAL",
"value": "GLOBAL",
"keyword": "GLOBAL",
"type": 1,
"flags": 1,
"position": 4
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 10
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "max_connections",
"value": "max_connections",
"keyword": null,
"type": 0,
"flags": 0,
"position": 11
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 26
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "=",
"value": "=",
"keyword": null,
"type": 2,
"flags": 2,
"position": 27
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 28
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "1",
"value": 1,
"keyword": null,
"type": 6,
"flags": 0,
"position": 29
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 10,
"idx": 10
},
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": {
"@type": "PhpMyAdmin\\SqlParser\\Parser",
"list": {
"@type": "@1"
},
"statements": [
{
"@type": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement",
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": {
"3": "GLOBAL"
}
},
"endOptions": null,
"set": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation",
"column": "max_connections",
"value": "1"
}
],
"first": 0,
"last": 8
}
],
"brackets": 0,
"strict": false,
"errors": []
},
"errors": {
"lexer": [],
"parser": []
}
}
1 change: 1 addition & 0 deletions tests/data/parser/parseSetVariable.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SET @foo = 1
124 changes: 124 additions & 0 deletions tests/data/parser/parseSetVariable.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"query": "SET @foo = 1",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"str": "SET @foo = 1",
"len": 12,
"last": 12,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "SET",
"value": "SET",
"keyword": "SET",
"type": 1,
"flags": 11,
"position": 0
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 3
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "@foo",
"value": "foo",
"keyword": null,
"type": 8,
"flags": 1,
"position": 4
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 8
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "=",
"value": "=",
"keyword": null,
"type": 2,
"flags": 2,
"position": 9
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 10
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "1",
"value": 1,
"keyword": null,
"type": 6,
"flags": 0,
"position": 11
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 8,
"idx": 8
},
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": {
"@type": "PhpMyAdmin\\SqlParser\\Parser",
"list": {
"@type": "@1"
},
"statements": [
{
"@type": "PhpMyAdmin\\SqlParser\\Statements\\SetStatement",
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"endOptions": null,
"set": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation",
"column": "@foo",
"value": "1"
}
],
"first": 0,
"last": 6
}
],
"brackets": 0,
"strict": false,
"errors": []
},
"errors": {
"lexer": [],
"parser": []
}
}

0 comments on commit 24d9cfa

Please sign in to comment.