diff --git a/src/Components/SetOperation.php b/src/Components/SetOperation.php index 47396fc7a..63bc66574 100644 --- a/src/Components/SetOperation.php +++ b/src/Components/SetOperation.php @@ -111,19 +111,27 @@ public static function parse(Parser $parser, TokensList $list, array $options = $commaLastSeenAt = $token; } } elseif ($state === 1) { - $tmp = Expression::parse( - $parser, - $list, - ['breakOnAlias' => true] - ); - if ($tmp === null) { - $parser->error('Missing expression.', $token); - break; + if ($token->flags & Token::FLAG_SYMBOL_PARAMETER) { + $expr->column = trim($expr->column); + $expr->value = $token->value; + $ret[] = $expr; + } else { + $tmp = Expression::parse( + $parser, + $list, + ['breakOnAlias' => true] + ); + + if ($tmp === null) { + $parser->error('Missing expression.', $token); + break; + } + + $expr->column = trim($expr->column); + $expr->value = $tmp->expr; + $ret[] = $expr; } - $expr->column = trim($expr->column); - $expr->value = $tmp->expr; - $ret[] = $expr; $expr = new static(); $state = 0; $commaLastSeenAt = null; diff --git a/tests/Parser/UpdateStatementTest.php b/tests/Parser/UpdateStatementTest.php index fa00ff081..ef12ab0f6 100644 --- a/tests/Parser/UpdateStatementTest.php +++ b/tests/Parser/UpdateStatementTest.php @@ -28,6 +28,7 @@ public static function updateProvider(): array ['parser/parseUpdate5'], ['parser/parseUpdate6'], ['parser/parseUpdate7'], + ['parser/parseUpdate8'], ['parser/parseUpdateErr'], ]; } diff --git a/tests/TestCase.php b/tests/TestCase.php index fc196ae24..45a4e8816 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -93,7 +93,7 @@ public function getErrorsAsArray($obj): array */ public function getData(string $name): array { - $serializedData = file_get_contents('tests/data/' . $name . '.out'); + $serializedData = file_get_contents(__DIR__ . '/data/' . $name . '.out'); $this->assertIsString($serializedData); $serializer = new CustomJsonSerializer(); diff --git a/tests/data/parser/parseUpdate8.in b/tests/data/parser/parseUpdate8.in new file mode 100644 index 000000000..ff1582c96 --- /dev/null +++ b/tests/data/parser/parseUpdate8.in @@ -0,0 +1,11 @@ +UPDATE + users +SET + username = ?, + id=155; + +UPDATE + users +SET + username = :user_name, + id=155; \ No newline at end of file