Skip to content

Commit

Permalink
Fix fullTablename(), ensure prefix prepending is only skipped when no…
Browse files Browse the repository at this point in the history
…t on position 0 in tablename. Fixes #2750
  • Loading branch information
ceeram committed Apr 4, 2012
1 parent 77f698d commit d209882
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions lib/Cake/Test/Case/Model/Datasource/DboSourceTest.php
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit d209882

Please sign in to comment.