From daf02cad61a0979fe6cf85b0aa4e5f2d68a03c2b Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 14 Mar 2010 23:31:52 -0400 Subject: [PATCH] Fixing CakeSchema index comparison that was causing failures in postgres tests. --- cake/libs/model/schema.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/schema.php b/cake/libs/model/schema.php index 30c1a37da50..db68169b1a7 100644 --- a/cake/libs/model/schema.php +++ b/cake/libs/model/schema.php @@ -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']; } }