Skip to content

Commit

Permalink
Fixing CakeSchema index comparison that was causing failures in postg…
Browse files Browse the repository at this point in the history
…res tests.
  • Loading branch information
markstory committed Mar 15, 2010
1 parent 3ab6870 commit daf02ca
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cake/libs/model/schema.php
Expand Up @@ -372,7 +372,7 @@ function write($object, $options = array()) {
*/
function compare($old, $new = null) {
if (empty($new)) {
$new = $this;
$new =& $this;
}
if (is_array($new)) {
if (isset($new['tables'])) {
Expand Down Expand Up @@ -406,6 +406,7 @@ function compare($old, $new = null) {
$tables[$table]['drop'] = $diff;
}
}

foreach ($fields as $field => $value) {
if (isset($old[$table][$field])) {
$diff = array_diff_assoc($value, $old[$table][$field]);
Expand All @@ -427,10 +428,13 @@ function compare($old, $new = null) {
if (isset($old[$table]['indexes']) && isset($new[$table]['indexes'])) {
$diff = $this->_compareIndexes($new[$table]['indexes'], $old[$table]['indexes']);
if ($diff) {
if (isset($tables[$table]['drop']['indexes']) && isset($diff['drop'])) {
if (!isset($tables[$table])) {
$tables[$table] = array();
}
if (isset($diff['drop'])) {
$tables[$table]['drop']['indexes'] = $diff['drop'];
}
if (isset($tables[$table]['add']['indexes']) && isset($diff['add'])) {
if ($diff && isset($diff['add'])) {
$tables[$table]['add']['indexes'] = $diff['add'];
}
}
Expand Down

0 comments on commit daf02ca

Please sign in to comment.