Skip to content

Commit 0076001

Browse files
committed
Fix operator ":=" not recognized on SET statement.
1 parent a3e700c commit 0076001

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Components/SetOperation.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PhpMyAdmin\SqlParser\TokensList;
1111

1212
use function implode;
13+
use function in_array;
1314
use function is_array;
1415
use function trim;
1516

@@ -63,7 +64,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
6364
* Below are the states of the parser.
6465
*
6566
* 0 ---------------------[ col_name ]--------------------> 0
66-
* 0 ------------------------[ = ]------------------------> 1
67+
* 0 ---------------------[ = or := ]---------------------> 1
6768
* 1 -----------------------[ value ]---------------------> 1
6869
* 1 ------------------------[ , ]------------------------> 0
6970
*
@@ -104,7 +105,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
104105
}
105106

106107
if ($state === 0) {
107-
if ($token->token === '=') {
108+
if (in_array($token->token, ['=', ':='], true)) {
108109
$state = 1;
109110
} elseif ($token->value !== ',') {
110111
$expr->column .= $token->token;

tests/data/parser/parseSetVariable2.out

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@
111111
"options": []
112112
},
113113
"end_options": null,
114-
"set": [],
114+
"set": [
115+
{
116+
"@type": "PhpMyAdmin\\SqlParser\\Components\\SetOperation",
117+
"column": "@foo",
118+
"value": "1"
119+
}
120+
],
115121
"first": 0,
116122
"last": 7
117123
}

0 commit comments

Comments
 (0)