Skip to content

Commit cc53e87

Browse files
authored
fixing upper function for pgsql (#641)
* fix: fixing upper function for pgsql * Fix styling --------- Co-authored-by: binaryk <[email protected]>
1 parent 203167c commit cc53e87

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Filters/SearchableFilter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public function filter(RestifyRequest $request, $query, $value)
4444
if (! config('restify.search.case_sensitive')) {
4545
$upper = strtoupper($value);
4646

47-
return $query->orWhereRaw("UPPER({$this->column}) LIKE ?", ['%'.$upper.'%']);
47+
$columnExpression = $connectionType === 'pgsql'
48+
? "UPPER({$this->column}::text)"
49+
: "UPPER({$this->column})";
50+
51+
return $query->orWhereRaw("{$columnExpression} LIKE ?", ['%'.$upper.'%']);
4852
}
4953

5054
return $query->orWhere($this->column, $likeOperator, "%{$value}%");

0 commit comments

Comments
 (0)