Skip to content

Commit 692cecf

Browse files
committed
Allow parsing ALTER TABLE statement with column check constraint
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
1 parent 29f982a commit 692cecf

File tree

4 files changed

+435
-1
lines changed

4 files changed

+435
-1
lines changed

src/Components/AlterOperation.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
422422
} elseif (($token->value === ',') && ($brackets === 0)) {
423423
break;
424424
}
425-
} elseif (! self::checkIfTokenQuotedSymbol($token) && $token->type !== Token::TYPE_STRING) {
425+
} elseif (
426+
! self::checkIfTokenQuotedSymbol($token) &&
427+
$token->type !== Token::TYPE_STRING &&
428+
$token->value !== 'CHECK'
429+
) {
426430
if (isset(Parser::$STATEMENT_PARSERS[$arrayKey]) && Parser::$STATEMENT_PARSERS[$arrayKey] !== '') {
427431
$list->idx++; // Ignore the current token
428432
$nextToken = $list->getNext();

tests/Parser/AlterStatementTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function alterProvider(): array
4545
['parser/parseAlterTablePartitionByRange1'],
4646
['parser/parseAlterTablePartitionByRange2'],
4747
['parser/parseAlterTableCoalescePartition'],
48+
['parser/parseAlterTableAddColumnWithCheck'],
4849
['parser/parseAlterTableAddSpatialIndex1'],
4950
['parser/parseAlterTableDropAddIndex1'],
5051
['parser/parseAlterTableDropColumn1'],
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `xx` ADD `json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`json`));

0 commit comments

Comments
 (0)