Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow parsing ALTER TABLE statement with column check constraint
Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
  • Loading branch information
MoonE committed Apr 18, 2024
commit 692cecfd0587ceadb73d708293e740f35316c2ef
6 changes: 5 additions & 1 deletion src/Components/AlterOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ public static function parse(Parser $parser, TokensList $list, array $options =
} elseif (($token->value === ',') && ($brackets === 0)) {
break;
}
} elseif (! self::checkIfTokenQuotedSymbol($token) && $token->type !== Token::TYPE_STRING) {
} elseif (
! self::checkIfTokenQuotedSymbol($token) &&
$token->type !== Token::TYPE_STRING &&
$token->value !== 'CHECK'
) {
if (isset(Parser::$STATEMENT_PARSERS[$arrayKey]) && Parser::$STATEMENT_PARSERS[$arrayKey] !== '') {
$list->idx++; // Ignore the current token
$nextToken = $list->getNext();
Expand Down
1 change: 1 addition & 0 deletions tests/Parser/AlterStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function alterProvider(): array
['parser/parseAlterTablePartitionByRange1'],
['parser/parseAlterTablePartitionByRange2'],
['parser/parseAlterTableCoalescePartition'],
['parser/parseAlterTableAddColumnWithCheck'],
['parser/parseAlterTableAddSpatialIndex1'],
['parser/parseAlterTableDropAddIndex1'],
['parser/parseAlterTableDropColumn1'],
Expand Down
1 change: 1 addition & 0 deletions tests/data/parser/parseAlterTableAddColumnWithCheck.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `xx` ADD `json` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`json`));
Loading