Skip to content

Commit 7d32ece

Browse files
committed
Implement DROP CHECK statement
1 parent 5b0693a commit 7d32ece

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/WP_SQLite_Driver_Tests.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9179,8 +9179,13 @@ public function testAlterTableAddCheckConstraint(): void {
91799179
}
91809180

91819181
public function testAlterTableDropCheckConstraint(): void {
9182-
$this->assertQuery( 'CREATE TABLE t (id INT, CONSTRAINT c CHECK (id > 0))' );
9183-
$this->assertQuery( 'ALTER TABLE t DROP CONSTRAINT c' );
9182+
$this->assertQuery( 'CREATE TABLE t (id INT, CONSTRAINT c1 CHECK (id > 0), CONSTRAINT c2 CHECK (id < 10))' );
9183+
9184+
// DROP CONSTRAINT syntax.
9185+
$this->assertQuery( 'ALTER TABLE t DROP CONSTRAINT c1' );
9186+
9187+
// DROP CHECK syntax.
9188+
$this->assertQuery( 'ALTER TABLE t DROP CHECK c2' );
91849189

91859190
// SHOW CREATE TABLE
91869191
$this->assertQuery( 'SHOW CREATE TABLE t' );

wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,13 @@ public function record_alter_table( WP_Parser_Node $node ): void {
682682
continue;
683683
}
684684

685+
// DROP CHECK
686+
if ( $action->has_child_token( WP_MySQL_Lexer::CHECK_SYMBOL ) ) {
687+
$name = $this->get_value( $action->get_first_child_node( 'identifier' ) );
688+
$this->record_drop_check_constraint( $table_is_temporary, $table_name, $name );
689+
continue;
690+
}
691+
685692
// DROP [COLUMN]
686693
$column_ref = $action->get_first_child_node( 'fieldIdentifier' );
687694
if ( null !== $column_ref ) {

0 commit comments

Comments
 (0)