GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Explicitly handle case where keyword encountered before alias value f… · phpmyadmin/sql-parser@f72a44c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/Components
    • CaseExpression.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Components/CaseExpression.php‎

Copy file name to clipboardExpand all lines: src/Components/CaseExpression.php
+10-8Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,21 @@ public static function parse(Parser $parser, TokensList $list, array $options =
227227
&& $token->keyword === 'AS'){
228228

229229
if ($asFound || !empty($ret->alias)) {
230-
$parser->error(
231-
'Potential duplicate alias of CASE expression.',
232-
$token
233-
);
230+
$parser->error('Potential duplicate alias of CASE expression.', $token);
234231
break;
235232
}
236233
$asFound = true;
237234
continue;
238235
}
239236

237+
if ($asFound
238+
&& $token->type === Token::TYPE_KEYWORD
239+
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED || $token->flags & Token::FLAG_KEYWORD_FUNCTION)){
240+
$parser->error('An alias expected after AS but got '.$token->value, $token);
241+
$asFound = false;
242+
break;
243+
}
244+
240245
if ($asFound
241246
|| $token->type === Token::TYPE_STRING
242247
|| ($token->type === Token::TYPE_SYMBOL && !$token->flags & Token::FLAG_SYMBOL_VARIABLE)
@@ -257,10 +262,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
257262
break;
258263
}
259264
if ($asFound) {
260-
$parser->error(
261-
'An alias was expected after AS.',
262-
$list->tokens[$list->idx - 1]
263-
);
265+
$parser->error('An alias was expected after AS.', $list->tokens[$list->idx - 1]);
264266
}
265267

266268

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.