Skip to content

Commit

Permalink
Fixing issue where habtm tables would not have the connection prefix …
Browse files Browse the repository at this point in the history
…removed when generating schema. Fixes #1180
  • Loading branch information
markstory committed Feb 5, 2011
1 parent cf50cbd commit 8d5e68d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cake/libs/model/cake_schema.php
Expand Up @@ -274,11 +274,16 @@ function read($options = array()) {
}
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]);
}
}
Expand Down

0 comments on commit 8d5e68d

Please sign in to comment.