Skip to content

Commit 4077a82

Browse files
committed
Merge branch '5.9.x'
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
2 parents 8d77322 + ec459f7 commit 4077a82

File tree

13 files changed

+1760
-14
lines changed

13 files changed

+1760
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

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

11+
## [5.8.2] - 2023-09-19
12+
13+
- Fix a regression with the ALTER operation (#511)
14+
1115
## [5.8.1] - 2023-09-15
1216

1317
- Fix `:=` was not recognized as an operator just like `=` (#306)

src/Components/AlterOperation.php

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -400,33 +400,26 @@ public static function parse(Parser $parser, TokensList $list, array $options =
400400
} elseif (($token->value === ',') && ($brackets === 0)) {
401401
break;
402402
}
403-
} elseif (! self::checkIfTokenQuotedSymbol($token)) {
404-
// If the current token is "SET" or "ENUM", we want to avoid the token between their parenthesis in
405-
// the unknown tokens.
406-
if (in_array($token->value, ['SET', 'ENUM'], true)) {
403+
} elseif (! self::checkIfTokenQuotedSymbol($token) && $token->type !== Token::TYPE_STRING) {
404+
if (isset(Parser::STATEMENT_PARSERS[$arrayKey]) && Parser::STATEMENT_PARSERS[$arrayKey] !== '') {
407405
$list->idx++; // Ignore the current token
408406
$nextToken = $list->getNext();
409407

410-
if ($nextToken !== null && $nextToken->value === '(') {
408+
if ($token->value === 'SET' && $nextToken !== null && $nextToken->value === '(') {
409+
// To avoid adding the tokens between the SET() parentheses to the unknown tokens
411410
$list->getNextOfTypeAndValue(Token::TYPE_OPERATOR, ')');
412-
} elseif ($nextToken !== null && $nextToken->value === 'DEFAULT') {
411+
} elseif ($token->value === 'SET' && $nextToken !== null && $nextToken->value === 'DEFAULT') {
413412
// to avoid adding the `DEFAULT` token to the unknown tokens.
414413
++$list->idx;
415414
} else {
415+
// We have reached the end of ALTER operation and suddenly found
416+
// a start to new statement, but have not found a delimiter between them
416417
$parser->error(
417418
'A new statement was found, but no delimiter between it and the previous one.',
418419
$token
419420
);
420421
break;
421422
}
422-
} elseif (! empty(Parser::STATEMENT_PARSERS[$arrayKey])) {
423-
// We have reached the end of ALTER operation and suddenly found
424-
// a start to new statement, but have not found a delimiter between them
425-
$parser->error(
426-
'A new statement was found, but no delimiter between it and the previous one.',
427-
$token
428-
);
429-
break;
430423
} elseif (
431424
(array_key_exists($arrayKey, self::DATABASE_OPTIONS)
432425
|| array_key_exists($arrayKey, self::TABLE_OPTIONS))

tests/Misc/BugsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ public static function bugProvider(): array
2828
['bugs/gh9'],
2929
['bugs/gh14'],
3030
['bugs/gh16'],
31+
['bugs/gh234'],
3132
['bugs/gh317'],
33+
['bugs/gh478'],
3234
['bugs/gh508'],
35+
['bugs/gh511'],
3336
['bugs/pma11800'],
3437
['bugs/pma11836'],
3538
['bugs/pma11843'],

tests/data/bugs/gh234.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `mail_template` CHANGE COLUMN `mtpl_group` `mtpl_group` ENUM('ORDER') NULL DEFAULT NULL ;

0 commit comments

Comments
 (0)