Permalink
Browse files

Fixing issue where habtm tables would not have the connection prefix …

…removed when generating schema. Fixes #1180
  • Loading branch information...
1 parent cf50cbd commit 8d5e68d582ef13f32534d1d185176acecf8c5060 @markstory markstory committed Feb 5, 2011
Showing with 8 additions and 3 deletions.
  1. +8 −3 cake/libs/model/cake_schema.php
@@ -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]);
}
}

0 comments on commit 8d5e68d

Please sign in to comment.