Skip to content

Commit 318f60f

Browse files
committed
Bugfix
1 parent 6bd4009 commit 318f60f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `laravel-cross-eloquent-search` will be documented in this file
44

5+
## 2.2.1 - 2021-09-17
6+
7+
- Bugfix for JSON columns
8+
59
## 2.2.0 - 2021-09-17
610

711
- Support for ordering by relevance

src/Searcher.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Database\Eloquent\Builder;
66
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
77
use Illuminate\Database\Query\Builder as QueryBuilder;
8+
use Illuminate\Database\Query\Grammars\MySqlGrammar;
89
use Illuminate\Pagination\Paginator;
910
use Illuminate\Support\Collection;
1011
use Illuminate\Support\Facades\DB;
@@ -354,7 +355,9 @@ private function addRelevanceQueryToBuilder($builder, $modelToSearchThrough)
354355
return;
355356
}
356357

357-
$expressionsAndBindings = $modelToSearchThrough->getQualifiedColumns()->flatMap(function ($field) use ($builder) {
358+
$expressionsAndBindings = $modelToSearchThrough->getQualifiedColumns()->flatMap(function ($field) {
359+
$field = (new MySqlGrammar)->wrap($field);
360+
358361
return $this->termsWithoutWildcards->map(function ($term) use ($field) {
359362
return [
360363
'expression' => "COALESCE(CHAR_LENGTH(LOWER({$field})) - CHAR_LENGTH(REPLACE(LOWER({$field}), ?, ?)), 0)",

0 commit comments

Comments
 (0)