Skip to content

Commit a8a749a

Browse files
dotMavriQclaude
andcommitted
fix: add identifier quoting in WithAccentInsensitiveSearch
Use query grammar wrap() for column names in whereRaw SQL instead of direct string concatenation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 77389d8 commit a8a749a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

app/Livewire/Concerns/WithAccentInsensitiveSearch.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44

55
namespace App\Livewire\Concerns;
66

7+
use Illuminate\Support\Facades\DB;
8+
79
trait WithAccentInsensitiveSearch
810
{
911
private function applyAccentInsensitiveSearch($query, string $search, array $columns): void
1012
{
13+
$grammar = DB::connection()->getQueryGrammar();
1114
$words = preg_split('/\s+/', trim($search));
1215

1316
foreach ($words as $word) {
14-
$query->where(function ($q) use ($word, $columns) {
17+
$query->where(function ($q) use ($word, $columns, $grammar) {
1518
foreach ($columns as $column) {
16-
$q->orWhereRaw('unaccent(COALESCE(' . $column . ", '')) ILIKE unaccent(?)", ['%' . $word . '%']);
19+
$q->orWhereRaw('unaccent(COALESCE(' . $grammar->wrap($column) . ", '')) ILIKE unaccent(?)", ['%' . $word . '%']);
1720
}
1821
});
1922
}

0 commit comments

Comments
 (0)