spatie / laravel-query-builder

Easily build Eloquent queries from API requests

Home Page:https://spatie.be/docs/laravel-query-builder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PostgreSQL error on Filter Relationship

joaoVtr opened this issue · comments

Hi. I have a problem when i try to filter a relationship on QueryBuilder. Error SQLSTATE[42883] Undefined function: 7 ERROR: function lower

My error
image

My code

$query = QueryBuilder::for($this->model)
          ->allowedFilters($columns);

And my query
image

I'm using Laravel 9, PostgreSQL 13.5, PHP 8.1

The issue #73 have a similar problem, but i dont understood the solution.

Hi, i belive it's becouse of this line:

$sql = "LOWER({$wrappedProperty}) LIKE ?";

With some types of column you will be able to do it this way, but not for types like uuid, bigint...
the solution i found was to create a custom filter

and hi from Brazil, ES

@joaovdiasb Obrigado pela resposta. Também criei um filtro pra isso. Nos resta ficar de olho caso o pacote faça alguma atualização a respeito. vlw