diff --git a/src/Database/Type/DateTimeType.php b/src/Database/Type/DateTimeType.php index db6dcf37438..a06a0a259c5 100644 --- a/src/Database/Type/DateTimeType.php +++ b/src/Database/Type/DateTimeType.php @@ -146,7 +146,8 @@ public function toPHP($value, Driver $driver) return null; } - $instance = (clone $this->_datetimeInstance)->modify($value); + $instance = clone $this->_datetimeInstance; + $instance = $instance->modify($value); if ($this->setToDateStart) { $instance = $instance->setTime(0, 0, 0); @@ -172,7 +173,8 @@ public function manyToPHP(array $values, array $fields, Driver $driver) continue; } - $instance = (clone $this->_datetimeInstance)->modify($values[$field]); + $instance = clone $this->_datetimeInstance; + $instance = $instance->modify($value); if ($this->setToDateStart) { $instance = $instance->setTime(0, 0, 0); diff --git a/tests/TestCase/Database/QueryTest.php b/tests/TestCase/Database/QueryTest.php index 9c68ff87ea4..a3294b732e1 100644 --- a/tests/TestCase/Database/QueryTest.php +++ b/tests/TestCase/Database/QueryTest.php @@ -4475,7 +4475,7 @@ public function testCastResults() 'true' => 'boolean' ]); $results = $query - ->select(['one' => '1', 'two' => '2', 'true' => '1', 'three' => '3.0']) + ->select(['one' => '1 * 1', 'two' => '1 * 2', 'true' => '1', 'three' => '1 + 2']) ->setSelectTypeMap($typeMap) ->execute() ->fetchAll('assoc'); diff --git a/tests/TestCase/Database/Type/DateTimeTypeTest.php b/tests/TestCase/Database/Type/DateTimeTypeTest.php index 40e0a15534b..2ad01603d81 100644 --- a/tests/TestCase/Database/Type/DateTimeTypeTest.php +++ b/tests/TestCase/Database/Type/DateTimeTypeTest.php @@ -104,12 +104,10 @@ public function testManyToPHP() $values = [ 'a' => null, 'b' => '2001-01-04 12:13:14', - 'c' => '2001-01-04 12:13:14.12345', ]; $expected = [ 'a' => null, 'b' => new Time('2001-01-04 12:13:14'), - 'c' => new Time('2001-01-04 12:13:14.12345'), ]; $this->assertEquals( $expected, diff --git a/tests/TestCase/Database/Type/TimeTypeTest.php b/tests/TestCase/Database/Type/TimeTypeTest.php index d8594255c26..099745662a5 100644 --- a/tests/TestCase/Database/Type/TimeTypeTest.php +++ b/tests/TestCase/Database/Type/TimeTypeTest.php @@ -95,12 +95,10 @@ public function testManyToPHP() $values = [ 'a' => null, 'b' => '01:30:13', - 'c' => '12:13:14.12345', ]; $expected = [ 'a' => null, 'b' => new Time('01:30:13'), - 'c' => new Time('12:13:14.12345'), ]; $this->assertEquals( $expected,