EloquentFilter icon indicating copy to clipboard operation
EloquentFilter copied to clipboard

Postgresql support (case-insensitively)

Open garbinmarcelo opened this issue 3 years ago • 2 comments

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.

garbinmarcelo avatar Oct 17 '20 14:10 garbinmarcelo

Hi, Is there any solution to this issue?

Ian-Yy avatar Jan 29 '22 12:01 Ian-Yy

Hi, Is there any solution to this issue?

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

garbinmarcelo avatar Jan 29 '22 14:01 garbinmarcelo