Skip to content

Commit

Permalink
changes (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetry committed Jun 20, 2023
1 parent 9131c6e commit 3044f37
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Illuminate/Database/Query/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1389,7 +1389,7 @@ public function makeRawSql($sql, $bindings)
$bindings = array_map(fn ($value) => $this->escape($value), $bindings);
$query = '';

$isEscape = false;
$isStringLiteral = false;
for ($i = 0; $i < strlen($sql); $i++) {
$char = $sql[$i];
$nextChar = $sql[$i + 1] ?? null;
Expand All @@ -1401,8 +1401,8 @@ public function makeRawSql($sql, $bindings)
$i += 1;
} else if ($char === "'") {
$query .= $char;
$isEscape = !$isEscape;
} else if ($char === '?' && !$isEscape) {
$isStringLiteral = !$isStringLiteral;
} else if ($char === '?' && !$isStringLiteral) {
$query .= array_shift($bindings) ?? '?';
} else {
$query .= $char;
Expand Down
9 changes: 8 additions & 1 deletion src/Illuminate/Database/Query/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,14 @@ protected function parseJsonPathArrayKeys($attribute)
public function makeRawSql($sql, $bindings)
{
$query = parent::makeRawSql($sql, $bindings);
foreach ($this->operators as $operator) {
if (!str_contains($operator, '?')) {
continue;
}

$query = str_replace(str_replace('?', '??', $operator), $operator, $query);
}

return str_replace('??', '?', $query);
return $query;
}
}

0 comments on commit 3044f37

Please sign in to comment.