From 376f58873dab119a25cef7c027dceb88431295a9 Mon Sep 17 00:00:00 2001 From: eldadfux Date: Mon, 23 Feb 2026 18:56:18 +0100 Subject: [PATCH] fix: enhance error handling during statement execution Wrap the execute method in a try-catch block to process PDOExceptions, improving error management in SQL adapter operations. --- src/Database/Adapter/SQL.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Database/Adapter/SQL.php b/src/Database/Adapter/SQL.php index 16572e4a6..fb949dfa4 100644 --- a/src/Database/Adapter/SQL.php +++ b/src/Database/Adapter/SQL.php @@ -3273,7 +3273,11 @@ public function count(Document $collection, array $queries = [], ?int $max = nul $stmt->bindValue($key, $value, $this->getPDOType($value)); } - $this->execute($stmt); + try { + $this->execute($stmt); + } catch (PDOException $e) { + throw $this->processException($e); + } $result = $stmt->fetchAll(); $stmt->closeCursor(); @@ -3355,7 +3359,11 @@ public function sum(Document $collection, string $attribute, array $queries = [] $stmt->bindValue($key, $value, $this->getPDOType($value)); } - $this->execute($stmt); + try { + $this->execute($stmt); + } catch (PDOException $e) { + throw $this->processException($e); + } $result = $stmt->fetchAll(); $stmt->closeCursor();