Skip to content

Commit 166fa16

Browse files
committed
Simplify ON keyword check to only needed case
Signed-off-by: Nicolai Ehrhardt <245527909+predictor2718@users.noreply.github.com>
1 parent 4c45eac commit 166fa16

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Components/SetOperation.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,21 @@ public static function parse(Parser $parser, TokensList $list, array $options =
113113
$commaLastSeenAt = $token;
114114
}
115115
} elseif ($state === 1) {
116+
// Reserved keywords like ON are valid values in SET statements
117+
// (e.g. SET @@sql_log_bin = ON). Try parsing as expression first,
118+
// and if that fails, accept reserved keywords as literal values.
116119
$tmp = Expression::parse(
117120
$parser,
118121
$list,
119122
['breakOnAlias' => true]
120123
);
121-
if ($tmp === null) {
124+
if (
125+
$tmp === null
126+
&& $token->type === Token::TYPE_KEYWORD
127+
&& $token->value === 'ON'
128+
) {
129+
$tmp = new Expression($token->token);
130+
} elseif ($tmp === null) {
122131
$parser->error('Missing expression.', $token);
123132
break;
124133
}

0 commit comments

Comments
 (0)