spatie / laravel-query-builder

Easily build Eloquent queries from API requests
https://spatie.be/docs/laravel-query-builder
MIT License
4.06k stars 397 forks source link

PostgreSQL error on Filter Relationship #755

Closed joaoVtr closed 2 years ago

joaoVtr commented 2 years ago

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.

joaovdiasb commented 2 years ago

Hi, i belive it's becouse of this line: https://github.com/spatie/laravel-query-builder/blob/2e738da1ed5c34a452b1fc041862a5852ef8704d/src/Filters/FiltersPartial.php#L21 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

joaoVtr commented 2 years ago

@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