Skip to content

Commit

Permalink
normalizeRow(): removed extra float handling [Closes #307]
Browse files Browse the repository at this point in the history
The only thing left is to check if the string does not start with a period, because of SQLserver
- 0c2ebef
- #289
- https://learn.microsoft.com/cs-cz/sql/connect/php/formatting-decimals-pdo-sqlsrv-driver?view=sql-server-2017
  • Loading branch information
dg committed Aug 18, 2024
1 parent c7d2cc4 commit 6dd1773
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Database/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,9 @@ public static function normalizeRow(
$row[$key] = is_float($tmp = $value * 1) ? $value : $tmp;

} elseif ($type === Type::Float || $type === Type::Decimal) {
if (is_string($value) && ($pos = strpos($value, '.')) !== false) {
$value = rtrim(rtrim($pos === 0 ? "0$value" : $value, '0'), '.');
if (is_string($value) && str_starts_with($value, '.')) {
$value = '0' . $value;
}

$row[$key] = (float) $value;

} elseif ($type === Type::Boolean) {
Expand Down

0 comments on commit 6dd1773

Please sign in to comment.