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

Breaking change on 2.4.1 from 2.4.0 #160

Closed BastianErlerArbeit closed 3 years ago

BastianErlerArbeit commented 3 years ago

134

this Pullrequest is breaking our code because if you call whereIn with an empty Array in Laravel it returns query like

select * from some_table where 0 = 1

which gives 0 results.

But because

SomeModel::filter(['id'=>[]])

no longer calls the filter function we get a query like

select * from some_table

which returns all results.

Tucker-Eric commented 3 years ago

In your filter you can override the includeFilterInput function to not filter out empty arrays:

    protected function includeFilterInput($key, $value)
    {
        return $value !== '' && $value !== null;
    }
PaulBehrendtVentoro commented 3 years ago

Hey Tucker-Eric,

in my opinion this was an API-change hidden in a minor version. And caused us a downtime. I don't know your versioning scheme, but i would only keep this in v3, or not?

We are taking care of ourselves. But i could imagine more people coming here sooner or later.

Tucker-Eric commented 3 years ago

@PaulBehrendtVentoro Ahh, got it. Will get update out for this.

Thanks!