Tucker-Eric / EloquentFilter

An Eloquent Way To Filter Laravel Models And Their Relationships
http://tucker-eric.github.io/EloquentFilter
MIT License
1.72k stars 120 forks source link

Postgresql support (case-insensitively) #145

Closed garbinmarcelo closed 1 year ago

garbinmarcelo commented 4 years ago

Hi,

The following options are compatible with MySQL, but with Postgresql they do not work accordingly.

$this->whereLike($column, $string) $query->where($column, 'LIKE', '%'.$string.'%')
$this->whereBeginsWith($column, $string) $query->where($column, 'LIKE', $string.'%')
$this->whereEndsWith($column, $string) $query->where($column, 'LIKE', '%'.$string)

A simple change from "LIKE" to "ILIKE" (case-insensitively) would be necessary to make it work with Postgresql.

However, it would have to be done "automatically" or pass as a parameter according to QueryBuilder Equivalent.

In the "automatic" form, you can check the type of connection (DB_CONNECTION) that Laravel is using, as Laravel already has predefined connections, this test would give to check if the connection would be of the "mysql" or "pgsql" type and thus defining whether "LIKE" or "ILIKE" is used.

Ian-Yy commented 2 years ago

Hi, Is there any solution to this issue?

garbinmarcelo commented 2 years ago

Hi, Is there any solution to this issue?

Hi, I haven't seen this anymore. I've used ILIKE directly so far.