Fixing issue where habtm tables would not have the connection prefix removed when generating schema. Fixes #1180

This commit is contained in:
mark_story 2011-02-05 11:19:05 -05:00
parent cf50cbdd9d
commit 8d5e68d582

View file

@ -274,11 +274,16 @@ class CakeSchema extends Object {
} }
if (is_object($Object->$class)) { if (is_object($Object->$class)) {
$withTable = $db->fullTableName($Object->$class, false); $withTable = $db->fullTableName($Object->$class, false);
if ($prefix && strpos($withTable, $prefix) !== 0) {
continue;
}
if (in_array($withTable, $currentTables)) { if (in_array($withTable, $currentTables)) {
$key = array_search($withTable, $currentTables); $key = array_search($withTable, $currentTables);
$tables[$withTable] = $this->__columns($Object->$class); $noPrefixWith = str_replace($prefix, '', $withTable);
$tables[$withTable]['indexes'] = $db->index($Object->$class);
$tables[$withTable]['tableParameters'] = $db->readTableParameters($withTable); $tables[$noPrefixWith] = $this->__columns($Object->$class);
$tables[$noPrefixWith]['indexes'] = $db->index($Object->$class);
$tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable);
unset($currentTables[$key]); unset($currentTables[$key]);
} }
} }