Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Updating CakeSchema to pass a Model object into DboSource::fullTableN…
…ame(); Fixes schema's not correctly reading tablePrefixes.

Fixes #290
  • Loading branch information
markstory committed Nov 13, 2009
1 parent 61d56cd commit 2c5fa17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cake/libs/model/cake_schema.php
Expand Up @@ -245,7 +245,7 @@ function read($options = array()) {

if (is_object($Object) && $Object->useTable !== false) {
$Object->setDataSource($connection);
$table = $db->fullTableName($Object->useTable, false);
$table = $db->fullTableName($Object, false);

if (in_array($table, $currentTables)) {
$key = array_search($table, $currentTables);
Expand Down
11 changes: 10 additions & 1 deletion cake/tests/cases/libs/model/cake_schema.test.php
Expand Up @@ -457,8 +457,17 @@ function testSchemaRead() {
ConnectionManager::create('schema_prefix', $config);
$read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false));
$this->assertTrue(empty($read['tables']));
}

$SchemaPost =& ClassRegistry::init('SchemaPost');
$SchemaPost->table = 'sts';
$SchemaPost->tablePrefix = 'po';
$read = $this->Schema->read(array(
'connection' => 'test_suite',
'name' => 'TestApp',
'models' => array('SchemaPost')
));
$this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s');
}
/**
* test reading schema from plugins.
*
Expand Down

0 comments on commit 2c5fa17

Please sign in to comment.