#1520: Doctrine_Record->_isValueModified(...) must be a lit bit complex. Problem
with decimal field.
-------------------------------------+--------------------------------------
Reporter: nodkz | Owner: romanb
Type: defect | Status: new
Priority: major | Milestone: 1.0.3
Component: Record | Version: 1.0.2
Keywords: record modified numeric | Has_test: 0
Mystatus: Pending Core Response | Has_patch: 0
-------------------------------------+--------------------------------------
{{{
class Doctrine_Record
...
protected function _isValueModified($type, $old, $new)
{
if ($type == 'boolean' && (is_bool($old) || is_numeric($old)) &&
(is_bool($new) || is_numeric($new)) && $old == $new) {
return false;
} else {
return $old !== $new;
}
}
}}}
I have in my table decimal(18,2) fields, values have following view
XXXXXX.YY (for example 2367.00, 245.37)
So following code works incorrectly:
{{{
$amount = 200;
$BillItem = new BillItem(); // BillItem extends Doctrine_Record
$BillItem->amount = $amount;
$BillItem->save(); // <---- Make INSERT in DB
$id = $BillItem->id;
// Let's load this record from DB and again assign same value for amount.
$BillItem = Doctrine::getTable('BillItem')->find($id);
var_dump($BillItem->amount); <--- amount is string
$BillItem->amount = $amount;
$BillItem->save(); // <---- Make UPDATE in DB It's not gooood((((((
}}}
So function _isValueModified may have following code:
{{{
class Doctrine_Record
...
protected function _isValueModified($type, $old, $new)
{
if ($type == 'boolean' && (is_bool($old) || is_numeric($old)) &&
(is_bool($new) || is_numeric($new)) && $old == $new) {
return false;
} elseif($type == 'decimal' || $type == 'integer' || $type ==
'float') {
return $old*1 == $new*1;
else {
return $old !== $new;
}
}
}}}
--
Ticket URL: <http://trac.doctrine-project.org/ticket/1520>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"doctrine-svn" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---