diff --git a/cake/libs/model/cake_schema.php b/cake/libs/model/cake_schema.php index 7901cdf09..a1ea24ace 100644 --- a/cake/libs/model/cake_schema.php +++ b/cake/libs/model/cake_schema.php @@ -246,7 +246,6 @@ class CakeSchema extends Object { if (is_object($Object) && $Object->useTable !== false) { $Object->setDataSource($connection); $table = $db->fullTableName($Object, false); - if (in_array($table, $currentTables)) { $key = array_search($table, $currentTables); if (empty($tables[$table])) { @@ -263,7 +262,7 @@ class CakeSchema extends Object { if (is_object($Object->$class)) { $withTable = $db->fullTableName($Object->$class, false); if (in_array($withTable, $currentTables)) { - $key = array_search($table, $currentTables); + $key = array_search($withTable, $currentTables); $tables[$withTable] = $this->__columns($Object->$class); $tables[$withTable]['indexes'] = $db->index($Object->$class); $tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable); diff --git a/cake/tests/cases/libs/model/cake_schema.test.php b/cake/tests/cases/libs/model/cake_schema.test.php index c07b9d998..3a769356a 100644 --- a/cake/tests/cases/libs/model/cake_schema.test.php +++ b/cake/tests/cases/libs/model/cake_schema.test.php @@ -575,6 +575,13 @@ class CakeSchemaTest extends CakeTestCase { 'models' => array('SchemaPost') )); $this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix %s'); + + $read = $this->Schema->read(array( + 'connection' => 'test_suite', + 'name' => 'TestApp', + 'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost') + )); + $this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing %s'); } /**