Implemented Add IN and NOT IN operators for the finder

Sadik B

Well-known member
I see this,

PHP:
switch ($operator)
        {
            case '=':
            case '<>':
            case '!=':
            case '>':
            case '>=':
            case '<':
            case '<=':
            case 'LIKE':
            case 'NOT LIKE':
            case 'BETWEEN':
                break;

            default:
                throw new \InvalidArgumentException("Operator $operator is not valid");
        }


Not sure why the IN operator is excluded. It is useful in many cases when extending a repository. Else we have to use many whereOr conditions which doesn't seem ideal.
 
Upvote 0
This suggestion has been implemented. Votes are no longer accepted.
The = and != operators are automatically converted to "IN" and "NOT IN" when dealing with arrays.

LIKE and NOT LIKE are also compatible with using arrays
 
Indeed. There's a slightly different code path for array values. You'll notice on line 285 of XF\Mvc\Entity\Finder that if a non array value is used then it will return return "$lhs $operator $quoted";.

Below that it starts dealing with IN, NOT IN, LIKE and NOT LIKE etc.
 
Back
Top Bottom