diff --git a/src/Components/CaseExpression.php b/src/Components/CaseExpression.php index 19061db67..ab9076874 100644 --- a/src/Components/CaseExpression.php +++ b/src/Components/CaseExpression.php @@ -7,6 +7,7 @@ namespace PhpMyAdmin\SqlParser\Components; use PhpMyAdmin\SqlParser\Component; +use PhpMyAdmin\SqlParser\Context; use PhpMyAdmin\SqlParser\Parser; use PhpMyAdmin\SqlParser\Token; use PhpMyAdmin\SqlParser\TokensList; @@ -55,6 +56,13 @@ class CaseExpression extends Component */ public $else_result; + /** + * The alias of this CASE statement. + * + * @var string + */ + public $alias; + /** * The sub-expression. * @@ -70,8 +78,8 @@ public function __construct() } /** - * @param Parser $parser the parser that serves as context - * @param TokensList $list the list of tokens that are being parsed + * @param Parser $parser the parser that serves as context + * @param TokensList $list the list of tokens that are being parsed * @param array $options parameters for parsing * * @return CaseExpression @@ -199,6 +207,64 @@ public static function parse(Parser $parser, TokensList $list, array $options = $list->tokens[$list->idx - 1] ); } else { + // Parse for alias of CASE expression + $asFound = false; + for (; $list->idx < $list->count; ++$list->idx) { + $token = $list->tokens[$list->idx]; + + // End of statement. + if ($token->type === Token::TYPE_DELIMITER) { + break; + } + + // Skipping whitespaces and comments. + if (($token->type === Token::TYPE_WHITESPACE) + || ($token->type === Token::TYPE_COMMENT) + ) { + continue; + } + + // Handle optional AS keyword before alias + if ($token->type === Token::TYPE_KEYWORD + && $token->keyword === 'AS') { + if ($asFound || !empty($ret->alias)) { + $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) + || $token->type === Token::TYPE_NONE + ) { + // An alias is expected (the keyword `AS` was previously found). + if (!empty($ret->alias)) { + $parser->error('An alias was previously found.', $token); + break; + } + $ret->alias = $token->value; + $asFound = false; + + continue; + } + + break; + } + if ($asFound) { + $parser->error('An alias was expected after AS.', $list->tokens[$list->idx - 1]); + } + $ret->expr = self::build($ret); } @@ -239,6 +305,10 @@ public static function build($component, array $options = array()) } $ret .= 'END'; + if ($component->alias) { + $ret .= ' AS ' . Context::escape($component->alias); + } + return $ret; } } diff --git a/tests/Components/CaseExpressionTest.php b/tests/Components/CaseExpressionTest.php index afe5e6095..475486f3a 100644 --- a/tests/Components/CaseExpressionTest.php +++ b/tests/Components/CaseExpressionTest.php @@ -83,4 +83,32 @@ public function testParseBuild6() 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END' ); } + + public function testParseBuild7() + { + $caseExprQuery = 'case when 1=1 then "Some" ' + . 'when 1=2 then "SomeOther" end AS foo'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery) + ); + $this->assertEquals( + CaseExpression::build($component), + 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END AS `foo`' + ); + } + + public function testParseBuild8() + { + $caseExprQuery = 'case when 1=1 then "Some" ' + . 'when 1=2 then "SomeOther" end foo'; + $component = CaseExpression::parse( + new Parser(), + $this->getTokensList($caseExprQuery) + ); + $this->assertEquals( + CaseExpression::build($component), + 'CASE WHEN 1=1 THEN "Some" WHEN 1=2 THEN "SomeOther" END AS `foo`' + ); + } } diff --git a/tests/Parser/SelectStatementTest.php b/tests/Parser/SelectStatementTest.php index 747249f17..55b80ecce 100644 --- a/tests/Parser/SelectStatementTest.php +++ b/tests/Parser/SelectStatementTest.php @@ -51,6 +51,16 @@ public function testSelectProvider() array('parser/parseSelectCaseErr3'), array('parser/parseSelectCaseErr4'), array('parser/parseSelectCaseErr5'), + array('parser/parseSelectCaseAlias1'), + array('parser/parseSelectCaseAlias2'), + array('parser/parseSelectCaseAlias3'), + array('parser/parseSelectCaseAlias4'), + array('parser/parseSelectCaseAlias5'), + array('parser/parseSelectCaseAlias6'), + array('parser/parseSelectCaseAliasErr1'), + array('parser/parseSelectCaseAliasErr2'), + array('parser/parseSelectCaseAliasErr3'), + array('parser/parseSelectCaseAliasErr4'), array('parser/parseSelectIntoOptions1'), array('parser/parseSelectIntoOptions2'), array('parser/parseSelectIntoOptions3'), diff --git a/tests/data/parser/parseSelectCaseAlias1.in b/tests/data/parser/parseSelectCaseAlias1.in new file mode 100644 index 000000000..fe81f9d79 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias1.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case /* */ when 1=1 then "Some" when 2=1 then "Other" end /* */ AS /* */ foo FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias1.out b/tests/data/parser/parseSelectCaseAlias1.out new file mode 100644 index 000000000..c7c676ad6 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias1.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:166:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case /* */ when 1=1 then "Some" when 2=1 then "Other" end /* */ AS /* */ foo FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:166:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case /* */ when 1=1 then "Some" when 2=1 then "Other" end /* */ AS /* */ foo FROM a;";s:3:"len";i:166;s:4:"last";i:166;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:66:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:92;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:93;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:97;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:98;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:99;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:100;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:101;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:102;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:106;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:107;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:113;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:114;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:118;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"2";s:5:"value";i:2;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:119;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:120;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:121;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:122;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:123;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:128;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:135;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:136;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:139;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:140;}i:54;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:145;}i:55;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:146;}i:56;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:148;}i:57;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:149;}i:58;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:154;}i:59;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"foo";s:5:"value";s:3:"foo";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:155;}i:60;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:158;}i:61;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:159;}i:62;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:163;}i:63;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:164;}i:64;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:165;}i:65;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:66;s:3:"idx";i:66;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";N;s:10:"conditions";a:2:{i:0;a:1:{i:0;O:41:"PhpMyAdmin\SqlParser\Components\Condition":3:{s:11:"identifiers";a:0:{}s:10:"isOperator";b:0;s:4:"expr";s:3:"1=1";}}i:1;a:1:{i:0;O:41:"PhpMyAdmin\SqlParser\Components\Condition":3:{s:11:"identifiers";a:0:{}s:10:"isOperator";b:0;s:4:"expr";s:3:"2=1";}}}s:7:"results";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}i:1;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";N;s:11:"else_result";N;s:5:"alias";s:3:"foo";s:4:"expr";s:60:"CASE WHEN 1=1 THEN "Some" WHEN 2=1 THEN "Other" END AS `foo`";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:63;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias2.in b/tests/data/parser/parseSelectCaseAlias2.in new file mode 100644 index 000000000..1288173e9 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias2.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case /* */ when 1=1 then "Some" when 2=1 then "Other" end /* */ foo FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias2.out b/tests/data/parser/parseSelectCaseAlias2.out new file mode 100644 index 000000000..bffcaadf9 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias2.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:157:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case /* */ when 1=1 then "Some" when 2=1 then "Other" end /* */ foo FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:157:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case /* */ when 1=1 then "Some" when 2=1 then "Other" end /* */ foo FROM a;";s:3:"len";i:157;s:4:"last";i:157;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:62:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:92;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:93;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:97;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:98;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:99;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:100;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:101;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:102;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:106;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:107;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:113;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:114;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:118;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"2";s:5:"value";i:2;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:119;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:120;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:121;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:122;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:123;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:128;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:135;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:136;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:139;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:140;}i:54;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:145;}i:55;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"foo";s:5:"value";s:3:"foo";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:146;}i:56;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:149;}i:57;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:150;}i:58;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:154;}i:59;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:155;}i:60;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:156;}i:61;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:62;s:3:"idx";i:62;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";N;s:10:"conditions";a:2:{i:0;a:1:{i:0;O:41:"PhpMyAdmin\SqlParser\Components\Condition":3:{s:11:"identifiers";a:0:{}s:10:"isOperator";b:0;s:4:"expr";s:3:"1=1";}}i:1;a:1:{i:0;O:41:"PhpMyAdmin\SqlParser\Components\Condition":3:{s:11:"identifiers";a:0:{}s:10:"isOperator";b:0;s:4:"expr";s:3:"2=1";}}}s:7:"results";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}i:1;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";N;s:11:"else_result";N;s:5:"alias";s:3:"foo";s:4:"expr";s:60:"CASE WHEN 1=1 THEN "Some" WHEN 2=1 THEN "Other" END AS `foo`";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:59;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias3.in b/tests/data/parser/parseSelectCaseAlias3.in new file mode 100644 index 000000000..2da0fe86f --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias3.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +test=case 1 /* */ when 1 then "Some" when 2 then "Other" end /* */ AS /* */ foo FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias3.out b/tests/data/parser/parseSelectCaseAlias3.out new file mode 100644 index 000000000..8bbf030ed --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias3.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:169:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +test=case 1 /* */ when 1 then "Some" when 2 then "Other" end /* */ AS /* */ foo FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:169:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +test=case 1 /* */ when 1 then "Some" when 2 then "Other" end /* */ AS /* */ foo FROM a;";s:3:"len";i:169;s:4:"last";i:169;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:66:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"test";s:5:"value";s:4:"test";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:91;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:92;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:99;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:100;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:104;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:105;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:106;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:107;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:111;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:112;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:118;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:119;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:123;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"2";s:5:"value";i:2;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:124;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:125;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:126;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:130;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:131;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:138;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:139;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:142;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:143;}i:54;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:148;}i:55;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:149;}i:56;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:151;}i:57;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:152;}i:58;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:157;}i:59;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"foo";s:5:"value";s:3:"foo";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:158;}i:60;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:161;}i:61;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:162;}i:62;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:166;}i:63;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:167;}i:64;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:168;}i:65;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:66;s:3:"idx";i:66;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"test";s:4:"expr";s:69:"test=CASE 1 /* */ WHEN 1 THEN "Some" WHEN 2 THEN "Other" END AS `foo`";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:63;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias4.in b/tests/data/parser/parseSelectCaseAlias4.in new file mode 100644 index 000000000..b4d56238e --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias4.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +test=case 1 /* */ when 1 then "Some" when 2 then "Other" end /* */ foo FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias4.out b/tests/data/parser/parseSelectCaseAlias4.out new file mode 100644 index 000000000..874c8f39a --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias4.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:160:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +test=case 1 /* */ when 1 then "Some" when 2 then "Other" end /* */ foo FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:160:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +test=case 1 /* */ when 1 then "Some" when 2 then "Other" end /* */ foo FROM a;";s:3:"len";i:160;s:4:"last";i:160;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:62:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"test";s:5:"value";s:4:"test";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:91;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:92;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:99;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:100;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:104;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:105;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:106;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:107;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:111;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:112;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:118;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:119;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:123;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"2";s:5:"value";i:2;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:124;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:125;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:126;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:130;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:131;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:138;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:139;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:142;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"/* */";s:5:"value";s:5:"/* */";s:7:"keyword";N;s:4:"type";i:4;s:5:"flags";i:2;s:8:"position";i:143;}i:54;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:148;}i:55;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"foo";s:5:"value";s:3:"foo";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:149;}i:56;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:152;}i:57;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:153;}i:58;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:157;}i:59;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:158;}i:60;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:159;}i:61;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:62;s:3:"idx";i:62;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"test";s:4:"expr";s:69:"test=CASE 1 /* */ WHEN 1 THEN "Some" WHEN 2 THEN "Other" END AS `foo`";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:59;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias5.in b/tests/data/parser/parseSelectCaseAlias5.in new file mode 100644 index 000000000..ec99ffbf4 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias5.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS "string value" FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias5.out b/tests/data/parser/parseSelectCaseAlias5.out new file mode 100644 index 000000000..46fb30869 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias5.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:150:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS "string value" FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:150:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS "string value" FROM a;";s:3:"len";i:150;s:4:"last";i:150;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:54:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:88;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:89;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:95;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:96;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:100;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:101;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:107;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"else";s:5:"value";s:4:"ELSE";s:7:"keyword";s:4:"ELSE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:108;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:112;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:113;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:120;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:121;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:124;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:125;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:14:""string value"";s:5:"value";s:12:"string value";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:128;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:142;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:143;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:147;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:148;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:149;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:54;s:3:"idx";i:54;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:10:"conditions";N;s:7:"results";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:11:"else_result";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:5:"alias";s:12:"string value";s:4:"expr";s:60:"CASE 1 WHEN 1 THEN "Some" ELSE "Other" END AS `string value`";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:51;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias6.in b/tests/data/parser/parseSelectCaseAlias6.in new file mode 100644 index 000000000..e964f94c9 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias6.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS `symbol_value` FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAlias6.out b/tests/data/parser/parseSelectCaseAlias6.out new file mode 100644 index 000000000..5ff882fbb --- /dev/null +++ b/tests/data/parser/parseSelectCaseAlias6.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:150:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS `symbol_value` FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:150:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS `symbol_value` FROM a;";s:3:"len";i:150;s:4:"last";i:150;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:54:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:88;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:89;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:95;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:96;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:100;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:101;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:107;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"else";s:5:"value";s:4:"ELSE";s:7:"keyword";s:4:"ELSE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:108;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:112;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:113;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:120;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:121;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:124;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:125;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:14:"`symbol_value`";s:5:"value";s:12:"symbol_value";s:7:"keyword";N;s:4:"type";i:8;s:5:"flags";i:2;s:8:"position";i:128;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:142;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:143;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:147;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:148;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:149;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:54;s:3:"idx";i:54;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:10:"conditions";N;s:7:"results";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:11:"else_result";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:5:"alias";s:12:"symbol_value";s:4:"expr";s:60:"CASE 1 WHEN 1 THEN "Some" ELSE "Other" END AS `symbol_value`";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:51;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:0:{}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr1.in b/tests/data/parser/parseSelectCaseAliasErr1.in new file mode 100644 index 000000000..b00b077d3 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr1.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS AS foo FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr1.out b/tests/data/parser/parseSelectCaseAliasErr1.out new file mode 100644 index 000000000..5d66c6f91 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr1.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:142:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS AS foo FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:142:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS AS foo FROM a;";s:3:"len";i:142;s:4:"last";i:142;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:56:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:88;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:89;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:95;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:96;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:100;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:101;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:107;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"else";s:5:"value";s:4:"ELSE";s:7:"keyword";s:4:"ELSE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:108;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:112;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:113;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:120;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:121;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:124;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:125;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:128;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:130;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"foo";s:5:"value";s:3:"foo";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:131;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:134;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:135;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:139;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:140;}i:54;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:141;}i:55;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:56;s:3:"idx";i:56;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:10:"conditions";N;s:7:"results";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:11:"else_result";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:5:"alias";N;s:4:"expr";s:42:"CASE 1 WHEN 1 THEN "Some" ELSE "Other" END";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:53;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:4:{i:0;a:3:{i:0;s:45:"Potential duplicate alias of CASE expression.";i:1;r:338;i:2;i:0;}i:1;a:3:{i:0;s:31:"An alias was expected after AS.";i:1;r:331;i:2;i:0;}i:2;a:3:{i:0;s:21:"Unrecognized keyword.";i:1;r:338;i:2;i:0;}i:3;a:3:{i:0;s:17:"Unexpected token.";i:1;r:352;i:2;i:0;}}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr2.in b/tests/data/parser/parseSelectCaseAliasErr2.in new file mode 100644 index 000000000..861171310 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr2.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr2.out b/tests/data/parser/parseSelectCaseAliasErr2.out new file mode 100644 index 000000000..ad4e57f7b --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr2.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:135:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:135:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS FROM a;";s:3:"len";i:135;s:4:"last";i:135;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:52:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:88;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:89;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:95;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:96;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:100;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:101;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:107;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"else";s:5:"value";s:4:"ELSE";s:7:"keyword";s:4:"ELSE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:108;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:112;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:113;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:120;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:121;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:124;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:125;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:128;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:132;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:133;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:134;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:52;s:3:"idx";i:52;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:10:"conditions";N;s:7:"results";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:11:"else_result";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:5:"alias";N;s:4:"expr";s:42:"CASE 1 WHEN 1 THEN "Some" ELSE "Other" END";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:49;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:1:{i:0;a:3:{i:0;s:39:"An alias expected after AS but got FROM";i:1;r:338;i:2;i:0;}}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr3.in b/tests/data/parser/parseSelectCaseAliasErr3.in new file mode 100644 index 000000000..fde3e44c7 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr3.in @@ -0,0 +1,2 @@ +select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS foo bar FROM a; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr3.out b/tests/data/parser/parseSelectCaseAliasErr3.out new file mode 100644 index 000000000..827abfd47 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr3.out @@ -0,0 +1,4 @@ +a:4:{s:5:"query";s:143:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS foo bar FROM a;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:143:"select (SELECT name FROM mysql.help_category WHERE help_category_id = 1) as name, +case 1 when 1 then "Some" else "Other" end AS foo bar FROM a;";s:3:"len";i:143;s:4:"last";i:143;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:56:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"select";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"(";s:5:"value";s:1:"(";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:8;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:14;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:15;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:19;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:20;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:24;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"mysql";s:5:"value";s:5:"mysql";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:25;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:".";s:5:"value";s:1:".";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:30;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:13:"help_category";s:5:"value";s:13:"help_category";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:31;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:44;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:5:"WHERE";s:5:"value";s:5:"WHERE";s:7:"keyword";s:5:"WHERE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:45;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:50;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:16:"help_category_id";s:5:"value";s:16:"help_category_id";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:51;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"=";s:5:"value";s:1:"=";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:2;s:8:"position";i:68;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:69;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:70;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:")";s:5:"value";s:1:")";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:71;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:72;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"as";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:73;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:75;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"name";s:5:"value";s:4:"name";s:7:"keyword";s:4:"NAME";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:76;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:",";s:5:"value";s:1:",";s:7:"keyword";N;s:4:"type";i:2;s:5:"flags";i:16;s:8:"position";i:80;}i:26;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" +";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:81;}i:27;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"case";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:82;}i:28;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:86;}i:29;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:87;}i:30;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:88;}i:31;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"when";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:89;}i:32;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:93;}i:33;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"1";s:5:"value";i:1;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:94;}i:34;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:95;}i:35;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"then";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:96;}i:36;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:100;}i:37;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:""Some"";s:5:"value";s:4:"Some";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:101;}i:38;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:107;}i:39;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"else";s:5:"value";s:4:"ELSE";s:7:"keyword";s:4:"ELSE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:108;}i:40;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:112;}i:41;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:7:""Other"";s:5:"value";s:5:"Other";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:113;}i:42;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:120;}i:43;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"end";s:5:"value";s:3:"end";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:121;}i:44;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:124;}i:45;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:125;}i:46;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:127;}i:47;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"foo";s:5:"value";s:3:"foo";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:128;}i:48;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:131;}i:49;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"bar";s:5:"value";s:3:"bar";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:132;}i:50;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:135;}i:51;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"FROM";s:5:"value";s:4:"FROM";s:7:"keyword";s:4:"FROM";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:136;}i:52;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:140;}i:53;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"a";s:5:"value";s:1:"a";s:7:"keyword";N;s:4:"type";i:0;s:5:"flags";i:0;s:8:"position";i:141;}i:54;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:142;}i:55;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:56;s:3:"idx";i:56;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:2:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:65:"(SELECT name FROM mysql.help_category WHERE help_category_id = 1)";s:5:"alias";s:4:"name";s:8:"function";N;s:8:"subquery";s:6:"SELECT";}i:1;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:10:"conditions";N;s:7:"results";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:4:"Some";s:4:"expr";s:6:""Some"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";N;s:4:"expr";s:1:"1";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:11:"else_result";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:5:"Other";s:4:"expr";s:7:""Other"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:5:"alias";s:3:"foo";s:4:"expr";s:51:"CASE 1 WHEN 1 THEN "Some" ELSE "Other" END AS `foo`";}}s:4:"from";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";s:1:"a";s:6:"column";N;s:4:"expr";s:1:"a";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:53;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:2:{i:0;a:3:{i:0;s:30:"An alias was previously found.";i:1;r:352;i:2;i:0;}i:1;a:3:{i:0;s:17:"Unexpected token.";i:1;r:352;i:2;i:0;}}}} \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr4.in b/tests/data/parser/parseSelectCaseAliasErr4.in new file mode 100644 index 000000000..61c201418 --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr4.in @@ -0,0 +1 @@ +SELECT CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END AS ; \ No newline at end of file diff --git a/tests/data/parser/parseSelectCaseAliasErr4.out b/tests/data/parser/parseSelectCaseAliasErr4.out new file mode 100644 index 000000000..3d2618b0d --- /dev/null +++ b/tests/data/parser/parseSelectCaseAliasErr4.out @@ -0,0 +1 @@ +a:4:{s:5:"query";s:76:"SELECT CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END AS ;";s:5:"lexer";O:26:"PhpMyAdmin\SqlParser\Lexer":8:{s:3:"str";s:76:"SELECT CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END AS ;";s:3:"len";i:76;s:4:"last";i:76;s:4:"list";O:31:"PhpMyAdmin\SqlParser\TokensList":3:{s:6:"tokens";a:26:{i:0;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:6:"SELECT";s:5:"value";s:6:"SELECT";s:7:"keyword";s:6:"SELECT";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:0;}i:1;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:6;}i:2;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"CASE";s:5:"value";s:4:"CASE";s:7:"keyword";s:4:"CASE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:7;}i:3;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:11;}i:4;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"WHEN";s:5:"value";s:4:"WHEN";s:7:"keyword";s:4:"WHEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:12;}i:5;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:16;}i:6;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:"2";s:5:"value";i:2;s:7:"keyword";N;s:4:"type";i:6;s:5:"flags";i:0;s:8:"position";i:17;}i:7;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:18;}i:8;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"IS";s:5:"value";s:2:"IS";s:7:"keyword";s:2:"IS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:19;}i:9;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:21;}i:10;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"NULL";s:5:"value";s:4:"NULL";s:7:"keyword";s:4:"NULL";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:22;}i:11;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:26;}i:12;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"THEN";s:5:"value";s:4:"THEN";s:7:"keyword";s:4:"THEN";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:27;}i:13;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:31;}i:14;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:14:""this is true"";s:5:"value";s:12:"this is true";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:32;}i:15;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:46;}i:16;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:4:"ELSE";s:5:"value";s:4:"ELSE";s:7:"keyword";s:4:"ELSE";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:47;}i:17;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:51;}i:18;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:15:""this is false"";s:5:"value";s:13:"this is false";s:7:"keyword";N;s:4:"type";i:7;s:5:"flags";i:2;s:8:"position";i:52;}i:19;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:67;}i:20;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:3:"END";s:5:"value";s:3:"END";s:7:"keyword";s:3:"END";s:4:"type";i:1;s:5:"flags";i:1;s:8:"position";i:68;}i:21;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:71;}i:22;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:2:"AS";s:5:"value";s:2:"AS";s:7:"keyword";s:2:"AS";s:4:"type";i:1;s:5:"flags";i:3;s:8:"position";i:72;}i:23;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:" ";s:5:"value";s:1:" ";s:7:"keyword";N;s:4:"type";i:3;s:5:"flags";i:0;s:8:"position";i:74;}i:24;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";s:1:";";s:5:"value";s:1:";";s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";i:75;}i:25;O:26:"PhpMyAdmin\SqlParser\Token":6:{s:5:"token";N;s:5:"value";N;s:7:"keyword";N;s:4:"type";i:9;s:5:"flags";i:0;s:8:"position";N;}}s:5:"count";i:26;s:3:"idx";i:26;}s:9:"delimiter";s:1:";";s:12:"delimiterLen";i:1;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"parser";O:27:"PhpMyAdmin\SqlParser\Parser":5:{s:4:"list";r:7;s:10:"statements";a:1:{i:0;O:47:"PhpMyAdmin\SqlParser\Statements\SelectStatement":16:{s:4:"expr";a:1:{i:0;O:46:"PhpMyAdmin\SqlParser\Components\CaseExpression":7:{s:5:"value";N;s:10:"conditions";a:1:{i:0;a:1:{i:0;O:41:"PhpMyAdmin\SqlParser\Components\Condition":3:{s:11:"identifiers";a:0:{}s:10:"isOperator";b:0;s:4:"expr";s:9:"2 IS NULL";}}}s:7:"results";a:1:{i:0;O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:12:"this is true";s:4:"expr";s:14:""this is true"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}}s:14:"compare_values";N;s:11:"else_result";O:42:"PhpMyAdmin\SqlParser\Components\Expression":7:{s:8:"database";N;s:5:"table";N;s:6:"column";s:13:"this is false";s:4:"expr";s:15:""this is false"";s:5:"alias";N;s:8:"function";N;s:8:"subquery";N;}s:5:"alias";N;s:4:"expr";s:64:"CASE WHEN 2 IS NULL THEN "this is true" ELSE "this is false" END";}}s:4:"from";a:0:{}s:9:"partition";N;s:5:"where";N;s:5:"group";N;s:6:"having";N;s:5:"order";N;s:5:"limit";N;s:9:"procedure";N;s:4:"into";N;s:4:"join";N;s:5:"union";a:0:{}s:11:"end_options";N;s:7:"options";O:44:"PhpMyAdmin\SqlParser\Components\OptionsArray":1:{s:7:"options";a:0:{}}s:5:"first";i:0;s:4:"last";i:23;}}s:8:"brackets";i:0;s:6:"strict";b:0;s:6:"errors";a:0:{}}s:6:"errors";a:2:{s:5:"lexer";a:0:{}s:6:"parser";a:1:{i:0;a:3:{i:0;s:31:"An alias was expected after AS.";i:1;r:170;i:2;i:0;}}}} \ No newline at end of file