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)) {
$withTable = $db->fullTableName($Object->$class, false);
if ($prefix && strpos($withTable, $prefix) !== 0) {
continue;
}
if (in_array($withTable, $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);
$noPrefixWith = str_replace($prefix, '', $withTable);
$tables[$noPrefixWith] = $this->__columns($Object->$class);
$tables[$noPrefixWith]['indexes'] = $db->index($Object->$class);
$tables[$noPrefixWith]['tableParameters'] = $db->readTableParameters($withTable);
unset($currentTables[$key]);
}
}