forked from doctrine/doctrine1
-
Notifications
You must be signed in to change notification settings - Fork 76
Closed
Description
When I have a record with a field using double type. After calling the set method on a double field record row is always updated in the database even if the double value has not changed at all.
Detected symfony version: 1.5.14-dev
After some debugging I found that the _isValueModified method in Record.php does not properly check fields with double types. It matches as a string. Adding the double type check (in_array($type, array('decimal', 'float', 'double') into the condition will eliminate this problem.
protected function _isValueModified($type, $old, $new)
{
if ($new instanceof Doctrine_Expression) {
return true;
}
if ($type == 'boolean' && (is_bool($old) || is_numeric($old)) && (is_bool($new) || is_numeric($new)) && $old == $new) {
return false;
} else if (in_array($type, array('decimal', 'float', 'double')) && is_numeric($old) && is_numeric($new)) {
return $old * 100 != $new * 100;
} else if (in_array($type, array('integer', 'int')) && is_numeric($old) && is_numeric($new)) {
return $old != $new;
} else if ($type == 'timestamp' || $type == 'date') {
$oldStrToTime = @strtotime((string) $old);
$newStrToTime = @strtotime((string) $new);
if ($oldStrToTime && $newStrToTime) {
return $oldStrToTime !== $newStrToTime;
} else {
return $old !== $new;
}
} else {
return $old !== $new;
}
}
Metadata
Metadata
Assignees
Labels
No labels