Skip to content

Commit

Permalink
add double to type check. bug #88
Browse files Browse the repository at this point in the history
  • Loading branch information
connorhu authored and thePanz committed Jan 10, 2023
1 parent 0ee6863 commit 81c839b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Doctrine/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ 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 if (in_array($type, array('decimal', 'float')) && is_numeric($old) && is_numeric($new)) {
} 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;
Expand Down
12 changes: 12 additions & 0 deletions tests/RecordTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function prepareTables()
$this->tables[] = 'Book';
$this->tables[] = 'EntityAddress';
$this->tables[] = 'UnderscoreColumn';
$this->tables[] = 'Location2';
parent::prepareTables();
}

Expand Down Expand Up @@ -1022,4 +1023,15 @@ public function testDeleteReturnBooleanAndThrowsException()
$this->fail();
}
}

public function testDoubleIsModified()
{
$location = new Location2();
$location->lat = '12.345';

$location->save();
$location->lat = 12.345;

$this->assertFalse($location->isModified());
}
}
10 changes: 10 additions & 0 deletions tests/models/Location2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
class Location2 extends Doctrine_Record
{
public function setTableDefinition()
{
$this->hasColumn('id', 'integer', 10, array('primary' => true));
$this->hasColumn('lat', 'double', 10);
$this->hasColumn('lon', 'double', 10);
}
}

0 comments on commit 81c839b

Please sign in to comment.