Skip to content

Commit

Permalink
Merge branch '5.8.x' into 5.9.x
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Sep 19, 2023
2 parents cb58d58 + f1720ae commit ec459f7
Show file tree
Hide file tree
Showing 13 changed files with 1,760 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [5.9.x] - YYYY-MM-DD

## [5.8.2] - 2023-09-19

- Fix a regression with the ALTER operation (#511)

## [5.8.1] - 2023-09-15

- Fix `:=` was not recognized as an operator just like `=` (#306)
Expand Down
21 changes: 7 additions & 14 deletions src/Components/AlterOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,33 +426,26 @@ public static function parse(Parser $parser, TokensList $list, array $options =
} elseif (($token->value === ',') && ($brackets === 0)) {
break;
}
} elseif (! self::checkIfTokenQuotedSymbol($token)) {
// If the current token is "SET" or "ENUM", we want to avoid the token between their parenthesis in
// the unknown tokens.
if (in_array($token->value, ['SET', 'ENUM'], true)) {
} elseif (! self::checkIfTokenQuotedSymbol($token) && $token->type !== Token::TYPE_STRING) {
if (isset(Parser::$STATEMENT_PARSERS[$arrayKey]) && Parser::$STATEMENT_PARSERS[$arrayKey] !== '') {
$list->idx++; // Ignore the current token
$nextToken = $list->getNext();

if ($nextToken !== null && $nextToken->value === '(') {
if ($token->value === 'SET' && $nextToken !== null && $nextToken->value === '(') {
// To avoid adding the tokens between the SET() parentheses to the unknown tokens
$list->getNextOfTypeAndValue(Token::TYPE_OPERATOR, ')');
} elseif ($nextToken !== null && $nextToken->value === 'DEFAULT') {
} elseif ($token->value === 'SET' && $nextToken !== null && $nextToken->value === 'DEFAULT') {
// to avoid adding the `DEFAULT` token to the unknown tokens.
++$list->idx;
} else {
// We have reached the end of ALTER operation and suddenly found
// a start to new statement, but have not found a delimiter between them
$parser->error(
'A new statement was found, but no delimiter between it and the previous one.',
$token
);
break;
}
} elseif (! empty(Parser::$STATEMENT_PARSERS[$arrayKey])) {
// We have reached the end of ALTER operation and suddenly found
// a start to new statement, but have not found a delimiter between them
$parser->error(
'A new statement was found, but no delimiter between it and the previous one.',
$token
);
break;
} elseif (
(array_key_exists($arrayKey, self::$DB_OPTIONS)
|| array_key_exists($arrayKey, self::$TABLE_OPTIONS))
Expand Down
3 changes: 3 additions & 0 deletions tests/Misc/BugsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ public function bugProvider(): array
['bugs/gh9'],
['bugs/gh14'],
['bugs/gh16'],
['bugs/gh234'],
['bugs/gh317'],
['bugs/gh478'],
['bugs/gh508'],
['bugs/gh511'],
['bugs/pma11800'],
['bugs/pma11836'],
['bugs/pma11843'],
Expand Down
1 change: 1 addition & 0 deletions tests/data/bugs/gh234.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `mail_template` CHANGE COLUMN `mtpl_group` `mtpl_group` ENUM('ORDER') NULL DEFAULT NULL ;
Loading

0 comments on commit ec459f7

Please sign in to comment.