From 9593691cf555c43827b4f1ae5158e21f450d7232 Mon Sep 17 00:00:00 2001 From: Dan <79267265+dansysanalyst@users.noreply.github.com> Date: Mon, 27 May 2024 18:08:04 +0200 Subject: [PATCH] [FIX] SQL Binding on `searchableRaw()` (#1573) * Fix binding on searchableRaw * add link on header --- README.md | 2 +- src/DataSource/Builder.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 934d2f170..74c073c8f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@
-

PowerGrid Logo

+

PowerGrid Logo

Latest Version Total Downloads diff --git a/src/DataSource/Builder.php b/src/DataSource/Builder.php index 1d117f5af..adff82ed7 100644 --- a/src/DataSource/Builder.php +++ b/src/DataSource/Builder.php @@ -153,7 +153,7 @@ public function filterContains(): Builder $query->when($search != '', function () use ($column, $query, $search, $table, $field, $hasColumn) { if (($sqlRaw = strval(data_get($column, 'searchableRaw')))) { - $query->orWhereRaw($sqlRaw . ' ' . Sql::like($query) . ' \'%' . $search . '%\''); + $query->orWhereRaw($sqlRaw . ' ' . Sql::like($query) . ' ?', ["%{$search}%"]); } if ($hasColumn && blank(data_get($column, 'searchableRaw'))) { @@ -164,7 +164,7 @@ public function filterContains(): Builder $driverName = $query->getConnection()->getConfig('driver'); if ($columnType === 'json' && strtolower($driverName) !== 'pgsql') { - $query->orWhereRaw("LOWER(`{$table}`.`{$field}`)" . Sql::like($query) . "?", '%' . $search . '%'); + $query->orWhereRaw("LOWER(`{$table}`.`{$field}`)" . Sql::like($query) . ' ?', ["%{$search}%"]); } else { $query->orWhere("{$table}.{$field}", Sql::like($query), "%{$search}%"); }