Skip to content

Commit

Permalink
SqlsrvDriver: enables SQLSRV_ATTR_FORMAT_DECIMALS (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 19, 2024
1 parent 6cd2fe8 commit 46682c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions src/Database/Drivers/Engines/SQLServerEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,6 @@ public function resolveColumnConverter(array $meta, TypeConverter $converter): ?
return match ($meta['nativeType']) {
'timestamp' => null, // timestamp does not mean time in sqlsrv
'bit' => $converter->convertBoolean ? $converter->toBool(...) : null,
'decimal', 'numeric',
'double', 'double precision', 'float', 'real', 'money', 'smallmoney' => fn($value): float => (float) (is_string($value) && str_starts_with($value, '.') ? '0' . $value : $value),
default => $converter->resolve($meta['nativeType']),
};
}
Expand Down
1 change: 1 addition & 0 deletions src/Database/Drivers/PDO/SQLSrv/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function connect(): Drivers\Connection
{
$connection = new Drivers\PDO\Connection(self::EngineClass, ...$this->params);
$connection->metaTypeKey = 'sqlsrv:decl_type';
$connection->pdo->setAttribute(\PDO::SQLSRV_ATTR_FORMAT_DECIMALS, true);
return $connection;
}

Expand Down

0 comments on commit 46682c3

Please sign in to comment.