Skip to content

Commit ec459f7

Browse files
committed
Merge branch '5.8.x' into 5.9.x
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
2 parents cb58d58 + f1720ae commit ec459f7

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
@@ -2,6 +2,10 @@
22

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

5+
## [5.8.2] - 2023-09-19
6+
7+
- Fix a regression with the ALTER operation (#511)
8+
59
## [5.8.1] - 2023-09-15
610

711
- 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
@@ -426,33 +426,26 @@ public static function parse(Parser $parser, TokensList $list, array $options =
426426
} elseif (($token->value === ',') && ($brackets === 0)) {
427427
break;
428428
}
429-
} elseif (! self::checkIfTokenQuotedSymbol($token)) {
430-
// If the current token is "SET" or "ENUM", we want to avoid the token between their parenthesis in
431-
// the unknown tokens.
432-
if (in_array($token->value, ['SET', 'ENUM'], true)) {
429+
} elseif (! self::checkIfTokenQuotedSymbol($token) && $token->type !== Token::TYPE_STRING) {
430+
if (isset(Parser::$STATEMENT_PARSERS[$arrayKey]) && Parser::$STATEMENT_PARSERS[$arrayKey] !== '') {
433431
$list->idx++; // Ignore the current token
434432
$nextToken = $list->getNext();
435433

436-
if ($nextToken !== null && $nextToken->value === '(') {
434+
if ($token->value === 'SET' && $nextToken !== null && $nextToken->value === '(') {
435+
// To avoid adding the tokens between the SET() parentheses to the unknown tokens
437436
$list->getNextOfTypeAndValue(Token::TYPE_OPERATOR, ')');
438-
} elseif ($nextToken !== null && $nextToken->value === 'DEFAULT') {
437+
} elseif ($token->value === 'SET' && $nextToken !== null && $nextToken->value === 'DEFAULT') {
439438
// to avoid adding the `DEFAULT` token to the unknown tokens.
440439
++$list->idx;
441440
} else {
441+
// We have reached the end of ALTER operation and suddenly found
442+
// a start to new statement, but have not found a delimiter between them
442443
$parser->error(
443444
'A new statement was found, but no delimiter between it and the previous one.',
444445
$token
445446
);
446447
break;
447448
}
448-
} elseif (! empty(Parser::$STATEMENT_PARSERS[$arrayKey])) {
449-
// We have reached the end of ALTER operation and suddenly found
450-
// a start to new statement, but have not found a delimiter between them
451-
$parser->error(
452-
'A new statement was found, but no delimiter between it and the previous one.',
453-
$token
454-
);
455-
break;
456449
} elseif (
457450
(array_key_exists($arrayKey, self::$DB_OPTIONS)
458451
|| 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
@@ -29,8 +29,11 @@ public function bugProvider(): array
2929
['bugs/gh9'],
3030
['bugs/gh14'],
3131
['bugs/gh16'],
32+
['bugs/gh234'],
3233
['bugs/gh317'],
34+
['bugs/gh478'],
3335
['bugs/gh508'],
36+
['bugs/gh511'],
3437
['bugs/pma11800'],
3538
['bugs/pma11836'],
3639
['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)