Add "TABLE" to list of keywords to recognize in addPrefixes()

This commit is contained in:
Kijin Sung 2025-09-30 22:27:36 +09:00
parent 5dcc0f92a4
commit 653ca4f697
2 changed files with 19 additions and 3 deletions

View file

@ -175,6 +175,22 @@ class DBTest extends \Codeception\Test\Unit
$target = 'INSERT INTO `' . $prefix . 'documents` (a, b, c) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE b = ?, c = ?';
$this->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));