diff --git a/common/framework/DB.php b/common/framework/DB.php index b436ce9e8..0f30246e8 100644 --- a/common/framework/DB.php +++ b/common/framework/DB.php @@ -1126,17 +1126,17 @@ class DB } else { - $exceptions = []; + $exceptions = ['TABLE']; } // Add prefixes to all other table names in the query string. - return preg_replace_callback('/\b((?:DELETE\s+)?FROM|JOIN|INTO|(?assertEquals($target, $oDB->addPrefixes($source)); + $source = "LOAD DATA LOCAL INFILE '/tmp/foo.csv' INTO TABLE foo_table FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n' (a, b, c)"; + $target = "LOAD DATA LOCAL INFILE '/tmp/foo.csv' INTO TABLE `" . $prefix . "foo_table` FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n' (a, b, c)"; + $this->assertEquals($target, $oDB->addPrefixes($source)); + + $source = 'ALTER TABLE documents ADD INDEX idx_foo (a, b)'; + $target = 'ALTER TABLE `' . $prefix . 'documents` ADD INDEX idx_foo (a, b)'; + $this->assertEquals($target, $oDB->addPrefixes($source)); + + $source = 'TRUNCATE TABLE documents'; + $target = 'TRUNCATE TABLE `' . $prefix . 'documents`'; + $this->assertEquals($target, $oDB->addPrefixes($source)); + + $source = 'DROP TABLE documents'; + $target = 'DROP TABLE `' . $prefix . 'documents`'; + $this->assertEquals($target, $oDB->addPrefixes($source)); + $source = 'update documents set a = ?, b = ? where c = ?'; $this->assertEquals($source, $oDB->addPrefixes($source));