diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-01 09:32:42 -0800 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-11-01 09:32:42 -0800 |
commit | 808fd4d3a0f38a2ea80bb8d56e1f8c6ce499e42d (patch) | |
tree | 2bf6392d68eb4a532f386daa7cf99f5aade7e5a3 | |
parent | 488b67014b44baf8bb19deaf7c77e87a95be220b (diff) |
Update the modified with a local fix for Kohana ticket #2298
-rw-r--r-- | modules/gallery/tests/Database_Test.php | 22 | ||||
-rw-r--r-- | system/libraries/Database.php | 12 |
2 files changed, 27 insertions, 7 deletions
diff --git a/modules/gallery/tests/Database_Test.php b/modules/gallery/tests/Database_Test.php index d83212ad..ad2bbba1 100644 --- a/modules/gallery/tests/Database_Test.php +++ b/modules/gallery/tests/Database_Test.php @@ -99,7 +99,7 @@ class Database_Test extends Unit_Test_Case { UNIQUE KEY(`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"; $this->assert_same($expected, $converted); - + $sql = "UPDATE {test_tables} SET `name` = '{test string}' " . "WHERE `item_id` IN " . " (SELECT `id` FROM {items} " . @@ -116,12 +116,16 @@ class Database_Test extends Unit_Test_Case { $this->assert_same($expected, $sql); } - public function setup() { - } + function prefix_no_replacement_test() { + $update = Database_For_Test::instance()->from("test_tables") + ->where("1 = 1") + ->set(array("name" => "Test Name")) + ->update(); - public function teardown() { - } + $expected = "UPDATE `g3test_test_tables` SET `name` = 'Test Name' WHERE 1 = 1"; + $this->assert_same($expected, $update); + } } class Database_For_Test extends Database { @@ -131,4 +135,12 @@ class Database_For_Test extends Database { $db->config["table_prefix"] = "g3test_"; return $db; } + + public function query($sql = '') { + if (!empty($sql)) { + print " query($sql)\n"; + $sql = $this->add_table_prefixes($sql); + } + return $sql; + } } diff --git a/system/libraries/Database.php b/system/libraries/Database.php index 2039371c..4cd29c58 100644 --- a/system/libraries/Database.php +++ b/system/libraries/Database.php @@ -1031,8 +1031,12 @@ class Database_Core { $table = $this->from[0]; } + else + { + $table = $this->config['table_prefix'].$table; + } - $sql = $this->driver->merge($this->config['table_prefix'].$table, array_keys($this->set), array_values($this->set)); + $sql = $this->driver->merge($table, array_keys($this->set), array_values($this->set)); $this->reset_write(); return $this->query($sql); @@ -1068,8 +1072,12 @@ class Database_Core { $table = $this->from[0]; } + else + { + $table = $this->config['table_prefix'].$table; + } - $sql = $this->driver->update($this->config['table_prefix'].$table, $this->set, $this->where); + $sql = $this->driver->update($table, $this->set, $this->where); $this->reset_write(); return $this->query($sql); |