diff --git a/src/Database/Helpers.php b/src/Database/Helpers.php index ee955693a..c85accc8c 100644 --- a/src/Database/Helpers.php +++ b/src/Database/Helpers.php @@ -216,8 +216,7 @@ public static function normalizeRow(array $row, ResultSet $resultSet): array $value = rtrim(rtrim($pos === 0 ? "0$value" : $value, '0'), '.'); } - $float = (float) $value; - $row[$key] = (string) $float === $value ? $float : $value; + $row[$key] = (float) $value; } elseif ($type === IStructure::FIELD_BOOL) { $row[$key] = ((bool) $value) && $value !== 'f' && $value !== 'F'; diff --git a/tests/Database/ResultSet.normalizeRow.postgre.phpt b/tests/Database/ResultSet.normalizeRow.postgre.phpt index 6e78caa53..2266c2469 100644 --- a/tests/Database/ResultSet.normalizeRow.postgre.phpt +++ b/tests/Database/ResultSet.normalizeRow.postgre.phpt @@ -18,10 +18,7 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . '/files/pgsql-nette_ $connection->query("SET TIMEZONE TO 'UTC'"); $res = $connection->query('SELECT * FROM types'); - $row = $res->fetch(); -Assert::type('string', $row->money); -unset($row->money); Assert::equal([ 'smallint' => 1, @@ -30,6 +27,7 @@ Assert::equal([ 'numeric' => 1.0, 'real' => 1.1, 'double' => 1.11, + 'money' => 0.0, 'bool' => true, 'date' => new DateTime('2012-10-13'), 'time' => new DateTime('10:10:10'), diff --git a/tests/Database/ResultSet.normalizeRow.sqlsrv.phpt b/tests/Database/ResultSet.normalizeRow.sqlsrv.phpt index 89eb42afe..e93ef75e1 100644 --- a/tests/Database/ResultSet.normalizeRow.sqlsrv.phpt +++ b/tests/Database/ResultSet.normalizeRow.sqlsrv.phpt @@ -26,7 +26,7 @@ Assert::equal([ 'datetime' => new DateTime('2012-10-13 10:10:10'), 'datetime2' => new DateTime('2012-10-13 10:10:10'), 'decimal' => 1.0, - 'float' => '1.1000000000000001', + 'float' => 1.1, 'geography' => "\xe6\x10\x00\x00\x01\x14\x87\x16\xd9\xce\xf7\xd3G@\xd7\xa3p=\n\x97^\xc0\x87\x16\xd9\xce\xf7\xd3G@\xcb\xa1E\xb6\xf3\x95^\xc0", 'geometry' => "\x00\x00\x00\x00\x01\x04\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00Y@\x00\x00\x00\x00\x00\x00Y@\x00\x00\x00\x00\x00\x004@\x00\x00\x00\x00\x00\x80f@\x00\x00\x00\x00\x00\x80f@\x00\x00\x00\x00\x00\x80f@\x01\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x02", 'hierarchyid' => 'X',