Permalink
Browse files

Fixing CakeSchema index comparison that was causing failures in postg…

…res tests.
  • Loading branch information...
markstory committed Mar 15, 2010
1 parent 3ab6870 commit daf02cad61a0979fe6cf85b0aa4e5f2d68a03c2b
Showing with 7 additions and 3 deletions.
  1. +7 −3 cake/libs/model/schema.php
View
@@ -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'])) {
@@ -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]);
@@ -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'];
}
}

0 comments on commit daf02ca

Please sign in to comment.