nestjsx / crud

NestJs CRUD for RESTful APIs
https://github.com/nestjsx/crud/wiki
MIT License
4.04k stars 533 forks source link

[BUG] Query param Search is not working with filter condition $in #746

Closed adrianogpena closed 2 years ago

adrianogpena commented 2 years ago

I'm trying to make my filter and the only problem is when I try to do an $in inside the search query param.

I'm trying to get everything when the "field" is 245 or 220 ?s={"field":{"$in":245,220}}

Before when I used like this it worked, I got all the results that I wanted &filter=field||$in||245,200

The error that I got is not useful { "statusCode": 400, "message": "Invalid column 'field' value", "error": "Bad Request" }

Because not only it was working before, but is also work if I try to use $eq ?s={"field":{"$eq":245}} - OK ?s={"field":{"$eq":220}} - OK ?s={"field":{"$in":245,220}} - Error

adrianogpena commented 2 years ago

I found the problem, the $in needs [ ] to work on the search params. ?s={"field":{"$in":[245,220]}} - OK

But for some reason this was really difficult to discover.