Skip to content

Commit

Permalink
Explicitly handle case where keyword encountered before alias value f…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
mostertb committed Oct 13, 2018
1 parent f2127a1 commit f72a44c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Components/CaseExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,21 @@ public static function parse(Parser $parser, TokensList $list, array $options =
&& $token->keyword === 'AS'){

if ($asFound || !empty($ret->alias)) {
$parser->error(
'Potential duplicate alias of CASE expression.',
$token
);
$parser->error('Potential duplicate alias of CASE expression.', $token);
break;
}
$asFound = true;
continue;
}

if ($asFound
&& $token->type === Token::TYPE_KEYWORD
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED || $token->flags & Token::FLAG_KEYWORD_FUNCTION)){
$parser->error('An alias expected after AS but got '.$token->value, $token);
$asFound = false;
break;
}

if ($asFound
|| $token->type === Token::TYPE_STRING
|| ($token->type === Token::TYPE_SYMBOL && !$token->flags & Token::FLAG_SYMBOL_VARIABLE)
Expand All @@ -257,10 +262,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
break;
}
if ($asFound) {
$parser->error(
'An alias was expected after AS.',
$list->tokens[$list->idx - 1]
);
$parser->error('An alias was expected after AS.', $list->tokens[$list->idx - 1]);
}


Expand Down

0 comments on commit f72a44c

Please sign in to comment.