Skip to content
Browse files

Fix fullTablename(), ensure prefix prepending is only skipped when no…

…t on position 0 in tablename. Fixes #2750
  • Loading branch information...
1 parent 77f698d commit d2098828c6ff1ef01b8c6958fa57785a6e907ed7 @ceeram ceeram committed Apr 4, 2012
View
2 lib/Cake/Model/Datasource/DboSource.php
@@ -922,7 +922,7 @@ public function fullTableName($model, $quote = true, $schema = true) {
if (is_object($model)) {
$schemaName = $model->schemaName;
$table = $model->tablePrefix . $model->table;
- } elseif (!empty($this->config['prefix']) && strpos($model, $this->config['prefix']) === false) {
+ } elseif (!empty($this->config['prefix']) && strpos($model, $this->config['prefix']) !== 0) {
$table = $this->config['prefix'] . strval($model);
} else {
$table = strval($model);
View
4 lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
@@ -746,6 +746,10 @@ public function testFullTablePermutations() {
$Article->schemaName = null;
$result = $noschema->fullTableName($Article, false, true);
$this->assertEquals('articles', $result);
+
+ $this->testDb->config['prefix'] = 't_';
+ $result = $this->testDb->fullTableName('post_tag', false, false);
+ $this->assertEquals('t_post_tag', $result);
}
/**

0 comments on commit d209882

Please sign in to comment.
Something went wrong with that request. Please try again.