Fix fullTablename(), ensure prefix prepending is only skipped when not on position 0 in tablename. Fixes #2750

This commit is contained in:
Ceeram 2012-04-04 15:00:36 +02:00
parent 77f698dbcd
commit d2098828c6
2 changed files with 5 additions and 1 deletions

View file

@ -922,7 +922,7 @@ class DboSource extends DataSource {
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 file

@ -746,6 +746,10 @@ class DboSourceTest extends CakeTestCase {
$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);
}
/**