Permalink
Browse files

BUGFIX Setting level in DataObject->getChangedFields() to 'value chan…

…ge' rather than 'type change' for CompositeFields, so they save correctly (fixes #6726, thanks frankmullenger)
  • Loading branch information...
1 parent dcf5995 commit c630f8334470108d3607ea08698f6e245bc763e0 @chillu chillu committed Oct 7, 2011
Showing with 3 additions and 2 deletions.
  1. +1 −1 model/DataObject.php
  2. +2 −1 tests/model/MoneyTest.php
View
@@ -1979,7 +1979,7 @@ public function getChangedFields($databaseFieldsOnly = false, $changeLevel = 1)
// Update the changed array with references to changed obj-fields
foreach($this->record as $k => $v) {
if(is_object($v) && method_exists($v, 'isChanged') && $v->isChanged()) {
- $this->changed[$k] = 1;
+ $this->changed[$k] = 2;
}
}
@@ -45,7 +45,8 @@ function testDataObjectChangedFields() {
$this->assertType('Money', $obj->MyMoney);
$obj->MyMoney->setAmount(99);
$changed = $obj->getChangedFields();
- $this->assertContains('MyMoney', array_keys($changed));
+ $this->assertContains('MyMoney', array_keys($changed), 'Field is detected as changed');
+ $this->assertEquals(2, $changed['MyMoney']['level'], 'Correct change level');
}
function testCanOverwriteSettersWithNull() {

0 comments on commit c630f83

Please sign in to comment.