Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Components/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
} else {
// The expression ended.
$expr->expr = trim($expr->expr);
if (! empty($expr->expr)) {
if ($expr->expr !== '') {
$ret[] = $expr;
}

Expand Down Expand Up @@ -214,7 +214,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =

// Last iteration was not processed.
$expr->expr = trim($expr->expr);
if (! empty($expr->expr)) {
if ($expr->expr !== '') {
$ret[] = $expr;
}

Expand Down
1 change: 1 addition & 0 deletions tests/data/parser/parseWhere0.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DELETE FROM t where 0 AND 0
208 changes: 208 additions & 0 deletions tests/data/parser/parseWhere0.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
{
"query": "DELETE FROM t where 0 AND 0",
"lexer": {
"@type": "PhpMyAdmin\\SqlParser\\Lexer",
"str": "DELETE FROM t where 0 AND 0",
"len": 27,
"last": 27,
"list": {
"@type": "PhpMyAdmin\\SqlParser\\TokensList",
"tokens": [
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "DELETE",
"value": "DELETE",
"keyword": "DELETE",
"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": "FROM",
"value": "FROM",
"keyword": "FROM",
"type": 1,
"flags": 3,
"position": 7
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 11
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "t",
"value": "t",
"keyword": null,
"type": 0,
"flags": 0,
"position": 12
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 13
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "where",
"value": "WHERE",
"keyword": "WHERE",
"type": 1,
"flags": 3,
"position": 14
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 19
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "0",
"value": 0,
"keyword": null,
"type": 6,
"flags": 0,
"position": 20
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 21
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "AND",
"value": "AND",
"keyword": "AND",
"type": 1,
"flags": 3,
"position": 22
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": " ",
"value": " ",
"keyword": null,
"type": 3,
"flags": 0,
"position": 25
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "0",
"value": 0,
"keyword": null,
"type": 6,
"flags": 0,
"position": 26
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": null,
"value": null,
"keyword": null,
"type": 9,
"flags": 0,
"position": null
}
],
"count": 14,
"idx": 14
},
"delimiter": ";",
"delimiterLen": 1,
"strict": false,
"errors": []
},
"parser": {
"@type": "PhpMyAdmin\\SqlParser\\Parser",
"list": {
"@type": "@1"
},
"statements": [
{
"@type": "PhpMyAdmin\\SqlParser\\Statements\\DeleteStatement",
"from": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Expression",
"database": null,
"table": "t",
"column": null,
"expr": "t",
"alias": null,
"function": null,
"subquery": null
}
],
"join": null,
"using": null,
"columns": null,
"partition": null,
"where": [
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [],
"isOperator": false,
"expr": "0"
},
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [],
"isOperator": true,
"expr": "AND"
},
{
"@type": "PhpMyAdmin\\SqlParser\\Components\\Condition",
"identifiers": [],
"isOperator": false,
"expr": "0"
}
],
"order": null,
"limit": null,
"options": {
"@type": "PhpMyAdmin\\SqlParser\\Components\\OptionsArray",
"options": []
},
"first": 0,
"last": 12
}
],
"brackets": 0,
"strict": false,
"errors": []
},
"errors": {
"lexer": [],
"parser": []
}
}