Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit dfee2dd

Browse files
committed
Move IF NOT EXISTS tests to driver tests
1 parent 0d0349e commit dfee2dd

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

tests/WP_SQLite_Driver_Tests.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,20 @@ public function testCreateTableIfNotExists(): void {
30793079
);
30803080
}
30813081

3082+
public function testCreateTemporaryTableIfNotExists(): void {
3083+
$this->assertQuery(
3084+
'CREATE TEMPORARY TABLE t (ID INTEGER, name TEXT)'
3085+
);
3086+
$this->assertQuery(
3087+
'CREATE TEMPORARY TABLE IF NOT EXISTS t (ID INTEGER, name TEXT)'
3088+
);
3089+
3090+
$this->expectExceptionMessage( 'table `t` already exists' );
3091+
$this->assertQuery(
3092+
'CREATE TEMPORARY TABLE t (ID INTEGER, name TEXT)'
3093+
);
3094+
}
3095+
30823096
public function testTranslatesComplexDelete() {
30833097
$this->sqlite->query(
30843098
"CREATE TABLE wptests_dummy (

tests/WP_SQLite_Driver_Translation_Tests.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -401,23 +401,6 @@ public function testCreateTableWithPrimaryKeyAndAutoincrement(): void {
401401
);
402402
}
403403

404-
// @TODO: IF NOT EXISTS
405-
/*public function testCreateTableWithIfNotExists(): void {
406-
$this->assertQuery(
407-
'CREATE TABLE IF NOT EXISTS "t" ( "id" INTEGER ) STRICT',
408-
'CREATE TABLE IF NOT EXISTS t (id INT)'
409-
);
410-
411-
$this->assertExecutedInformationSchemaQueries(
412-
array(
413-
'INSERT INTO _wp_sqlite_mysql_information_schema_tables (table_schema, table_name, table_type, engine, row_format, table_collation)'
414-
. " VALUES ('wp', 't', 'BASE TABLE', 'InnoDB', 'Dynamic', 'utf8mb4_general_ci')",
415-
'INSERT INTO _wp_sqlite_mysql_information_schema_columns (table_schema, table_name, column_name, ordinal_position, column_default, is_nullable, data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_type, column_key, extra, privileges, column_comment, generation_expression, srs_id)'
416-
. " VALUES ('wp', 't', 'id', 1, null, 'YES', 'int', null, null, 10, 0, null, null, null, 'int', '', '', 'select,insert,update,references', '', '', null)",
417-
)
418-
);
419-
}*/
420-
421404
public function testCreateTableWithInlineUniqueIndexes(): void {
422405
$this->assertQuery(
423406
array(
@@ -496,19 +479,12 @@ public function testCreateTableWithStandaloneUniqueIndexes(): void {
496479
);
497480
}*/
498481

499-
// TODO: IF NOT EXISTS
500-
/*public function testCreateTemporaryTable(): void {
482+
public function testCreateTemporaryTable(): void {
501483
$this->assertQuery(
502484
'CREATE TEMPORARY TABLE `t` ( `id` INTEGER ) STRICT',
503485
'CREATE TEMPORARY TABLE t (id INT)'
504486
);
505-
506-
// With IF NOT EXISTS.
507-
$this->assertQuery(
508-
'CREATE TEMPORARY TABLE IF NOT EXISTS `t` ( `id` INTEGER ) STRICT',
509-
'CREATE TEMPORARY TABLE IF NOT EXISTS t (id INT)'
510-
);
511-
}*/
487+
}
512488

513489
public function testDropTemporaryTable(): void {
514490
// Create a temporary table first so DROP doesn't fail.

0 commit comments

Comments
 (0)