Skip to content

Commit 374653b

Browse files
committed
SqlsrvDriver: enables SQLSRV_ATTR_FORMAT_DECIMALS (BC break)
1 parent 7206217 commit 374653b

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/Database/Drivers/Engines/SQLServerEngine.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ public function resolveColumnConverter(array $meta, TypeConverter $converter): ?
227227
return match ($meta['nativeType']) {
228228
'timestamp' => null, // timestamp does not mean time in sqlsrv
229229
'bit' => $converter->convertBoolean ? $converter->toBool(...) : $converter->toInt(...),
230-
'decimal', 'numeric',
231-
'double', 'double precision', 'float', 'real', 'money', 'smallmoney' => fn($value): float => (float) (is_string($value) && str_starts_with($value, '.') ? '0' . $value : $value),
232230
default => $converter->resolve($meta['nativeType']),
233231
};
234232
}

src/Database/Drivers/PDO/SQLSrv/Driver.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function connect(): Drivers\Connection
3333
{
3434
$connection = new Drivers\PDO\Connection(self::EngineClass, ...$this->params);
3535
$connection->metaTypeKey = 'sqlsrv:decl_type';
36+
$connection->pdo->setAttribute(\PDO::SQLSRV_ATTR_FORMAT_DECIMALS, true);
3637
return $connection;
3738
}
3839

0 commit comments

Comments
 (0)