From e9a203b72a2335655eef8d5ec56f1a8cdbb5bf77 Mon Sep 17 00:00:00 2001 From: QWERin Date: Sun, 5 Jan 2025 12:15:59 +0100 Subject: [PATCH 1/4] numeric type is int on MSSQL PDO --- src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php index 3731d102..ff8cb2e1 100644 --- a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php +++ b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php @@ -69,6 +69,7 @@ public function resolve(array $types): array 'int' => true, 'smallint' => true, 'tinyint' => true, + 'numeric'=>true, ]; static $dateTimes = [ From ae2b10c16833afaf118d05bf95fda20145104ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0kr=C3=A1=C5=A1ek?= Date: Sun, 5 Jan 2025 20:52:37 +0100 Subject: [PATCH 2/4] Update src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php --- src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php index ff8cb2e1..27d9e13e 100644 --- a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php +++ b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php @@ -69,7 +69,7 @@ public function resolve(array $types): array 'int' => true, 'smallint' => true, 'tinyint' => true, - 'numeric'=>true, + 'numeric' => true, ]; static $dateTimes = [ From 3536cbf4269b184119a8243c6b7b0859d4a148c0 Mon Sep 17 00:00:00 2001 From: qwerin Date: Wed, 8 Jan 2025 15:55:33 +0100 Subject: [PATCH 3/4] numeric precision 0 is int --- src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php | 3 +++ src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php index 8536ef3c..91bc1341 100644 --- a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php +++ b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php @@ -78,6 +78,9 @@ public function getTypes(): array throw new InvalidStateException("Should not happen."); } $types[$field['name']] = $field['sqlsrv:decl_type'] ?? null; // @phpstan-ignore-line + if($types[$field['name']] === 'numeric' && $field['precision'] === 0) { + $types[$field['name']] ='int'; + } } return $types; diff --git a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php index 27d9e13e..3731d102 100644 --- a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php +++ b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultNormalizerFactory.php @@ -69,7 +69,6 @@ public function resolve(array $types): array 'int' => true, 'smallint' => true, 'tinyint' => true, - 'numeric' => true, ]; static $dateTimes = [ From 6d1d87fa5de772b89cfad65e628da5c23971a59a Mon Sep 17 00:00:00 2001 From: qwerin Date: Wed, 8 Jan 2025 16:00:50 +0100 Subject: [PATCH 4/4] phpstan-ignore-line --- src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php index 91bc1341..9b2e6a88 100644 --- a/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php +++ b/src/Drivers/PdoSqlsrv/PdoSqlsrvResultAdapter.php @@ -78,8 +78,8 @@ public function getTypes(): array throw new InvalidStateException("Should not happen."); } $types[$field['name']] = $field['sqlsrv:decl_type'] ?? null; // @phpstan-ignore-line - if($types[$field['name']] === 'numeric' && $field['precision'] === 0) { - $types[$field['name']] ='int'; + if($types[$field['name']] === 'numeric' && $field['precision'] === 0) { // @phpstan-ignore-line + $types[$field['name']] ='int'; // @phpstan-ignore-line } }