diff options
author | William Desportes <williamdes@wdes.fr> | 2019-10-28 23:40:33 +0100 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2019-10-28 23:42:39 +0100 |
commit | 84535cf81aaa1906825ae6ee2e2f3ea7159d2742 (patch) | |
tree | e69073192106793ecffe4f4bc316a935d56dd196 | |
parent | b0cf7ec53ac2e9042387069655469c1798d7b584 (diff) | |
parent | e517fbbcaa58bbd1edf0921e3c0b7854caa28df5 (diff) | |
download | sql-parser-84535cf81aaa1906825ae6ee2e2f3ea7159d2742.zip sql-parser-84535cf81aaa1906825ae6ee2e2f3ea7159d2742.tar.gz sql-parser-84535cf81aaa1906825ae6ee2e2f3ea7159d2742.tar.bz2 |
Merge #264 - parse CHECK keyword on table definition
Ref: #167
Pull-request: #264
Signed-off-by: William Desportes <williamdes@wdes.fr>
-rw-r--r-- | src/Components/CreateDefinition.php | 7 | ||||
-rw-r--r-- | tests/Components/CreateDefinitionTest.php | 16 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/Components/CreateDefinition.php b/src/Components/CreateDefinition.php index ed79af7..0f44e09 100644 --- a/src/Components/CreateDefinition.php +++ b/src/Components/CreateDefinition.php @@ -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 diff --git a/tests/Components/CreateDefinitionTest.php b/tests/Components/CreateDefinitionTest.php index 3683e29..d00feea 100644 --- a/tests/Components/CreateDefinitionTest.php +++ b/tests/Components/CreateDefinitionTest.php @@ -63,4 +63,20 @@ class CreateDefinitionTest extends TestCase 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]) + ); + } } |