Skip to content

Commit 37e3593

Browse files
committed
SqlsrvDriver: enables SQLSRV_ATTR_FORMAT_DECIMALS (BC break)
1 parent 9d3d4fd commit 37e3593

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/Database/Drivers/Engines/SQLServerEngine.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ public function resolveTypeConverter(TypeConverter $converter, string $nativeTyp
3737
return match ($nativeType) {
3838
'timestamp' => null, // timestamp does not mean time in sqlsrv
3939
'bit' => $converter->convertBoolean ? fn($value) => (bool) $value : null,
40-
'decimal', 'numeric',
41-
'double', 'double precision', 'float', 'real', 'money', 'smallmoney' => fn($value) => (float) (is_string($value) && str_starts_with($value, '.') ? '0' . $value : $value),
4240
default => $converter->resolve($nativeType),
4341
};
4442
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public function getEngine(): Drivers\Engines\SQLServerEngine
2525
}
2626

2727

28+
protected function initialize(array $options): void
29+
{
30+
$this->pdo->setAttribute(\PDO::SQLSRV_ATTR_FORMAT_DECIMALS, true);
31+
}
32+
33+
2834
public function resolveColumnConverter(array $meta): ?\Closure
2935
{
3036
return isset($meta['sqlsrv:decl_type'])

0 commit comments

Comments
 (0)