From ca9ce8a83740efa567102191d60347279e70a25c Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Thu, 17 Oct 2024 19:00:18 +0200 Subject: [PATCH] Add try/catch for the substituteBindings --- src/DataCollector/QueryCollector.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/DataCollector/QueryCollector.php b/src/DataCollector/QueryCollector.php index 19fec2a64..69342b12d 100644 --- a/src/DataCollector/QueryCollector.php +++ b/src/DataCollector/QueryCollector.php @@ -623,8 +623,15 @@ private function getSqlQueryToDisplay(array $query): string { $sql = $query['query']; if ($query['type'] === 'query' && $this->renderSqlWithParams && method_exists(DB::connection($query['connection'])->getQueryGrammar(), 'substituteBindingsIntoRawSql')) { - $sql = DB::connection($query['connection'])->getQueryGrammar()->substituteBindingsIntoRawSql($sql, $query['bindings'] ?? []); - } elseif ($query['type'] === 'query' && $this->renderSqlWithParams) { + try { + $sql = DB::connection($query['connection'])->getQueryGrammar()->substituteBindingsIntoRawSql($sql, $query['bindings'] ?? []); + return $this->getDataFormatter()->formatSql($sql); + } catch (\Throwable $e) { + // Continue using the old substitute + } + } + + if ($query['type'] === 'query' && $this->renderSqlWithParams) { $bindings = $this->getDataFormatter()->checkBindings($query['bindings']); if (!empty($bindings)) { $pdo = null;