From 81c839b70c59ad417c8d9fbf8bdd100e2738c93c Mon Sep 17 00:00:00 2001 From: Karoly Gossler Date: Tue, 10 Jan 2023 12:24:05 +0100 Subject: [PATCH] add double to type check. bug #88 --- lib/Doctrine/Record.php | 2 +- tests/RecordTestCase.php | 12 ++++++++++++ tests/models/Location2.php | 10 ++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 tests/models/Location2.php diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 4ab93f04d..c64c6465a 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -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; diff --git a/tests/RecordTestCase.php b/tests/RecordTestCase.php index b0b06efb5..dc818570b 100644 --- a/tests/RecordTestCase.php +++ b/tests/RecordTestCase.php @@ -41,6 +41,7 @@ public function prepareTables() $this->tables[] = 'Book'; $this->tables[] = 'EntityAddress'; $this->tables[] = 'UnderscoreColumn'; + $this->tables[] = 'Location2'; parent::prepareTables(); } @@ -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()); + } } diff --git a/tests/models/Location2.php b/tests/models/Location2.php new file mode 100644 index 000000000..80ad551cf --- /dev/null +++ b/tests/models/Location2.php @@ -0,0 +1,10 @@ +hasColumn('id', 'integer', 10, array('primary' => true)); + $this->hasColumn('lat', 'double', 10); + $this->hasColumn('lon', 'double', 10); + } +}