saule
saule copied to clipboard
Saule cannot filter more than one input parameter.
Hi,
I tried to filter out with two input parameters with comma separated as defined by jsonapi.org but it always returns null.
http://example.com/articles/filter[something]=1234 works
http://example.com/articles/filter[something]=1245,1235 won't work.
is this feature missing?
Thanks
I think it's probably not supported yet, but you might be able to get it working using custom filter expressions. See here for more info.
I assume the value you'd get is the string including the comma.
Hi Jouke,
Has this already in place?
Please let me know.
Thanks!!
On Thu, Jun 2, 2016 at 1:20 PM, Jouke van der Maas <[email protected]
wrote:
I think it's probably not supported yet, but you might be able to get it working using custom filter expressions. See here https://github.com/joukevandermaas/saule/wiki/Queryable-endpoints#customizing-filtering-expressions for more info.
I assume the value you'd get is the string including the comma.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joukevandermaas/saule/issues/112#issuecomment-223217507, or mute the thread https://github.com/notifications/unsubscribe/ASxFnXQ_eR_WMYxwKD0H1yxorvewtBW0ks5qHoe4gaJpZM4IsHjH .
It isn't. I'm open to a PR but I don't have time to pick this up ATM.
If I wanted to pick this up what would be a good solution to escape a ","?
~Cheers
@PhyberApex I don't think we need to support escaping commas to be honest. If the spec doesn't mention it, it shouldn't be blocking us IMO.
Okay sure. This is going to be a problem for string fields tho for sure. In one of our use cases that would be a deal breaker tbh. We use the filter on a name field to validate for free names. We check if the response is empty. If so the name is free and we can validate it as okay. "," is not a disallowed character in our names. This implementation would actually break our current usage and potentially others. I am not sure that should be done tbh. Is there any mention on filters at all in the spec? iirc it only mentions filters and that what they do is up to you.
~Cheers
I suppose we could do like in CSV? So if the filter string is in quotes, we don't interpret the commas?
?filter[prop]="some,value"
=> checks that prop
is "some,value"
.
?filter[prop]=some,value
=> checks that prop
is some
or value
.
Just so I understand you correctly. This would mean I could not do a "or" filter on multiple strings containing "," is this correct?
~Cheers
It would be like ?filter[prop]="a,b","b,c"
, I think.
Okay I will probably take a look at this during this weekend. And open an PR when I'm ready.
~Cheers
I have this working now with strings. I can't quite figure out how to do it with enums or ints yet. Should I open the PR? Maybe you can give some insight on this. I think I am not proficient enough with LINQ to really get this done.
~Cheers
@PhyberApex a PR with the first steps would be great, thanks! If I remember right, the filtering code is pretty complex.
Done!