|
9 | 9 |
|
10 | 10 | namespace PhpMyAdmin\SqlParser; |
11 | 11 |
|
| 12 | +use PhpMyAdmin\SqlParser\Components\FunctionCall; |
12 | 13 | use PhpMyAdmin\SqlParser\Components\OptionsArray; |
13 | 14 |
|
14 | 15 | /** |
@@ -247,10 +248,10 @@ public function parse(Parser $parser, TokensList $list) |
247 | 248 | // Unions are parsed by the parser because they represent more than |
248 | 249 | // one statement. |
249 | 250 | if (($token->keyword === 'UNION') || |
250 | | - ($token->keyword === 'UNION ALL') || |
251 | | - ($token->keyword === 'UNION DISTINCT') || |
252 | | - ($token->keyword === 'EXCEPT') || |
253 | | - ($token->keyword === 'INTERSECT') |
| 251 | + ($token->keyword === 'UNION ALL') || |
| 252 | + ($token->keyword === 'UNION DISTINCT') || |
| 253 | + ($token->keyword === 'EXCEPT') || |
| 254 | + ($token->keyword === 'INTERSECT') |
254 | 255 | ) { |
255 | 256 | break; |
256 | 257 | } |
@@ -356,7 +357,7 @@ public function parse(Parser $parser, TokensList $list) |
356 | 357 | } elseif ($class === null) { |
357 | 358 | if ($this instanceof Statements\SelectStatement |
358 | 359 | && ($token->value === 'FOR UPDATE' |
359 | | - || $token->value === 'LOCK IN SHARE MODE') |
| 360 | + || $token->value === 'LOCK IN SHARE MODE') |
360 | 361 | ) { |
361 | 362 | // Handle special end options in Select statement |
362 | 363 | // See Statements\SelectStatement::$END_OPTIONS |
@@ -367,7 +368,7 @@ public function parse(Parser $parser, TokensList $list) |
367 | 368 | ); |
368 | 369 | } elseif ($this instanceof Statements\SetStatement |
369 | 370 | && ($token->value === 'COLLATE' |
370 | | - || $token->value === 'DEFAULT') |
| 371 | + || $token->value === 'DEFAULT') |
371 | 372 | ) { |
372 | 373 | // Handle special end options in SET statement |
373 | 374 | // See Statements\SetStatement::$END_OPTIONS |
@@ -398,6 +399,13 @@ public function parse(Parser $parser, TokensList $list) |
398 | 399 | } |
399 | 400 |
|
400 | 401 | $this->after($parser, $list, $token); |
| 402 | + |
| 403 | + // #223 Here may make a patch, if last is delimiter, back one |
| 404 | + if ((new $class()) instanceof FunctionCall) { |
| 405 | + if ($list->offsetGet($list->idx)->type === Token::TYPE_DELIMITER) { |
| 406 | + --$list->idx; |
| 407 | + } |
| 408 | + } |
401 | 409 | } |
402 | 410 |
|
403 | 411 | // This may be corrected by the parser. |
@@ -500,8 +508,8 @@ public function validateClauseOrder($parser, $list) |
500 | 508 | if ($clauseStartIdx !== -1 |
501 | 509 | && $this instanceof Statements\SelectStatement |
502 | 510 | && ($clauseType === 'FORCE' |
503 | | - || $clauseType === 'IGNORE' |
504 | | - || $clauseType === 'USE') |
| 511 | + || $clauseType === 'IGNORE' |
| 512 | + || $clauseType === 'USE') |
505 | 513 | ) { |
506 | 514 | // TODO: ordering of clauses in a SELECT statement with |
507 | 515 | // Index hints is not supported |
|