diff --git a/tests/WP_SQLite_Query_Tests.php b/tests/WP_SQLite_Query_Tests.php index 9605cc4..ff6e0aa 100644 --- a/tests/WP_SQLite_Query_Tests.php +++ b/tests/WP_SQLite_Query_Tests.php @@ -539,7 +539,7 @@ public function testOnDuplicateKeyWithUnnamedKeys() { public function testOnCreateTableIfNotExistsWithIndexAdded() { $this->assertQuery( - 'CREATE TABLE IF NOT EXISTS `test` ( + 'CREATE TABLE IF not EXISTS `test` ( `id` INT, `name` VARCHAR(255), `other` VARCHAR(255), @@ -548,7 +548,7 @@ public function testOnCreateTableIfNotExistsWithIndexAdded() { );' ); $this->assertQuery( - 'CREATE TABLE IF NOT EXISTS `test` ( + 'CREATE TABLE if NOT ExisTS `test` ( `id` INT, `name` VARCHAR(255), `other` VARCHAR(255), diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 5491c9b..fd0ed36 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -888,7 +888,7 @@ private function execute_create_table() { ')' ); - $if_not_exists = false === strpos( $create_query, 'IF NOT EXISTS' ) ? '' : 'IF NOT EXISTS'; + $if_not_exists = preg_match( '/\bIF\s+NOT\s+EXISTS\b/i', $create_query ) ? 'IF NOT EXISTS' : ''; $this->execute_sqlite_query( $create_query ); $this->results = $this->last_exec_returned;