File tree Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Expand file tree Collapse file tree 2 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -6581,4 +6581,24 @@ public function testRollbackNonExistentTransactionSavepoint(): void {
65816581 $ this ->expectExceptionMessage ( 'no such savepoint: sp1 ' );
65826582 $ this ->assertQuery ( 'ROLLBACK TO SAVEPOINT sp1 ' );
65836583 }
6584+
6585+ public function testForeignKeyConstraintAreIgnored (): void {
6586+ /*
6587+ * FOREIGN KEY constraints are not supported yet, they will be ignored.
6588+ * The following query will work, although it references a missing table.
6589+ */
6590+ $ this ->assertQuery ( 'CREATE TABLE t (id INT, CONSTRAINT c FOREIGN KEY (id) REFERENCES tt (id)) ' );
6591+ $ result = $ this ->assertQuery ( 'SHOW CREATE TABLE t ' );
6592+ $ this ->assertEquals (
6593+ implode (
6594+ "\n" ,
6595+ array (
6596+ 'CREATE TABLE `t` ( ' ,
6597+ ' `id` int DEFAULT NULL ' ,
6598+ ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci ' ,
6599+ )
6600+ ),
6601+ $ result [0 ]->{'Create Table ' }
6602+ );
6603+ }
65846604}
Original file line number Diff line number Diff line change @@ -1100,12 +1100,13 @@ private function record_add_constraint(
11001100 $ keyword = $ keyword ->get_first_child_token ();
11011101 }
11021102
1103- // FOREIGN KEY and CHECK constraints are not supported yet.
1104- if (
1105- WP_MySQL_Lexer::FOREIGN_SYMBOL === $ keyword ->id
1106- || WP_MySQL_Lexer::CHECK_SYMBOL === $ keyword ->id
1107- ) {
1108- throw new \Exception ( 'FOREIGN KEY and CHECK constraints are not supported yet. ' );
1103+ // FOREIGN KEY constraints are not supported yet; they will be ignored.
1104+ // @TODO: Implement support for FOREIGN KEY constraints.
1105+
1106+ // CHECK constraints are not supported yet.
1107+ // @TODO: Implement support for CHECK constraints.
1108+ if ( WP_MySQL_Lexer::CHECK_SYMBOL === $ keyword ->id ) {
1109+ throw new \Exception ( 'CHECK constraints are not supported yet. ' );
11091110 }
11101111
11111112 // PRIMARY KEY and UNIQUE require an index.
You can’t perform that action at this time.
0 commit comments