diff --git a/src/Medoo.php b/src/Medoo.php index 9509053a..2962b1aa 100644 --- a/src/Medoo.php +++ b/src/Medoo.php @@ -659,7 +659,7 @@ protected function buildRaw($raw, array &$map): ?string } $query = preg_replace_callback( - '/(([`\']).*?)?((FROM|TABLE|INTO|UPDATE|JOIN)\s*)?\<(([\p{L}_][\p{L}\p{N}@$#\-_]*)(\.[\p{L}_][\p{L}\p{N}@$#\-_]*)?)\>([^,]*?\2)?/u', + '/(([`\']).*?)?((FROM|TABLE|INTO|UPDATE|JOIN|TABLE IF EXISTS)\s*)?\<(([\p{L}_][\p{L}\p{N}@$#\-_]*)(\.[\p{L}_][\p{L}\p{N}@$#\-_]*)?)\>([^,]*?\2)?/u', function ($matches) { if (!empty($matches[2]) && isset($matches[8])) { return $matches[0]; diff --git a/tests/QueryTest.php b/tests/QueryTest.php index bff4d83e..3df3a828 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -56,6 +56,30 @@ public function testQueryWithPrefix() ); } + /** + * @covers ::query() + * @covers ::isRaw() + * @covers ::buildRaw() + */ + public function testQueryTableWithPrefix() + { + $database = new Medoo([ + 'testMode' => true, + 'prefix' => 'PREFIX_' + ]); + + $database->type = "sqlite"; + + $database->query("DROP TABLE IF EXISTS "); + + $this->assertQuery( + <<queryString + ); + } + /** * @covers ::query() * @covers ::isRaw()