Skip to content

Commit

Permalink
Manage "CHECK" keyword
Browse files Browse the repository at this point in the history
Even if this keyword is ignored by MySQL, it should be parsed.
Ref: #167

Signed-off-by: Hugues Peccatte <hugues.peccatte@aareon.fr>
  • Loading branch information
Hugues Peccatte authored and williamdes committed Oct 28, 2019
1 parent b35c21f commit e517fbb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Components/CreateDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ class CreateDefinition extends Component
),
'VIRTUAL' => 10,
'PERSISTENT' => 11,
'STORED' => 11
'STORED' => 11,
'CHECK' => array(
12,
'expr',
array('parenthesesDelimited' => true),
)
// Common entries.
//
// NOTE: Some of the common options are not in the same order which
Expand Down
16 changes: 16 additions & 0 deletions tests/Components/CreateDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,20 @@ public function testBuild()
CreateDefinition::build($parser->statements[0]->fields[1])
);
}

public function testBuild2()
{
$parser = new Parser(
'CREATE TABLE `payment` (' .
'-- snippet' . "\n" .
'`customer_id` smallint(5) unsigned NOT NULL,' .
'`customer_data` longtext CHARACTER SET utf8mb4 CHARSET utf8mb4_bin NOT NULL CHECK (json_valid(customer_data)),' .
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE' .
') ENGINE=InnoDB"'
);
$this->assertEquals(
'CONSTRAINT `fk_payment_customer` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`customer_id`) ON UPDATE CASCADE',
CreateDefinition::build($parser->statements[0]->fields[2])
);
}
}

0 comments on commit e517fbb

Please sign in to comment.