[limb-svn] r7123 - in 3.x/trunk/limb/active_record: src tests/cases
svn at limb-project.com
svn at limb-project.com
Fri Jul 18 18:35:41 MSD 2008
Author: conf
Date: 2008-07-18 18:35:41 +0400 (Fri, 18 Jul 2008)
New Revision: 7123
URL: http://fisheye.limb-project.com/changelog/limb/?cs=7123
Modified:
3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php
3.x/trunk/limb/active_record/tests/cases/lmbARDirtyTest.class.php
Log:
-- now AR property (table fields only) marks dirty only if it really changed its value
-- added test
Modified: 3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php
===================================================================
--- 3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php 2008-07-17 06:33:17 UTC (rev 7122)
+++ 3.x/trunk/limb/active_record/src/lmbActiveRecord.class.php 2008-07-18 14:35:41 UTC (rev 7123)
@@ -712,9 +712,15 @@
}
else
{
+ $old_value = $this->_getRaw($property);
+
parent :: set($property, $value);
-
- $this->_markDirtyProperty($property);
+
+ // if property is a table field and did not really changed, don't mark it dirty
+ if(!($this->_db_meta_info->hasColumn($property) && ($old_value === $value)))
+ {
+ $this->_markDirtyProperty($property);
+ }
}
}
Modified: 3.x/trunk/limb/active_record/tests/cases/lmbARDirtyTest.class.php
===================================================================
--- 3.x/trunk/limb/active_record/tests/cases/lmbARDirtyTest.class.php 2008-07-17 06:33:17 UTC (rev 7122)
+++ 3.x/trunk/limb/active_record/tests/cases/lmbARDirtyTest.class.php 2008-07-18 14:35:41 UTC (rev 7123)
@@ -76,6 +76,20 @@
$this->assertEqual($str, '|on_before_save||on_after_save|');
}
+ function testSettingSameTablePropertyValueDoesntMakeObjectDirty()
+ {
+ $object = new TestOneTableObject();
+ $object->setContent('whatever');
+ $object->save();
+ $this->assertFalse($object->isDirty());
+
+ $object->setContent($object->getContent());
+ $this->assertFalse($object->isDirty());
+
+ $object->setContent('whatever else');
+ $this->assertTrue($object->isDirty());
+ }
+
function testSettingNewParentObjectDoesntMakeNewObjectDirty()
{
$course = new CourseForTest();
More information about the limb-svn
mailing list