Skip to content

Commit 6a79909

Browse files
authored
Add try/catch for the substituteBindings (#1690)
1 parent b705c56 commit 6a79909

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/DataCollector/QueryCollector.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,15 @@ private function getSqlQueryToDisplay(array $query): string
623623
{
624624
$sql = $query['query'];
625625
if ($query['type'] === 'query' && $this->renderSqlWithParams && method_exists(DB::connection($query['connection'])->getQueryGrammar(), 'substituteBindingsIntoRawSql')) {
626-
$sql = DB::connection($query['connection'])->getQueryGrammar()->substituteBindingsIntoRawSql($sql, $query['bindings'] ?? []);
627-
} elseif ($query['type'] === 'query' && $this->renderSqlWithParams) {
626+
try {
627+
$sql = DB::connection($query['connection'])->getQueryGrammar()->substituteBindingsIntoRawSql($sql, $query['bindings'] ?? []);
628+
return $this->getDataFormatter()->formatSql($sql);
629+
} catch (\Throwable $e) {
630+
// Continue using the old substitute
631+
}
632+
}
633+
634+
if ($query['type'] === 'query' && $this->renderSqlWithParams) {
628635
$bindings = $this->getDataFormatter()->checkBindings($query['bindings']);
629636
if (!empty($bindings)) {
630637
$pdo = null;

0 commit comments

Comments
 (0)