saule icon indicating copy to clipboard operation
saule copied to clipboard

Saule cannot filter more than one input parameter.

Open dhirajdhakal09 opened this issue 8 years ago • 13 comments

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

dhirajdhakal09 avatar Jun 02 '16 01:06 dhirajdhakal09

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.

joukevandermaas avatar Jun 02 '16 07:06 joukevandermaas

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 .

dhirajdhakal09 avatar Jun 27 '16 06:06 dhirajdhakal09

It isn't. I'm open to a PR but I don't have time to pick this up ATM.

joukevandermaas avatar Jul 01 '16 07:07 joukevandermaas

If I wanted to pick this up what would be a good solution to escape a ","?

~Cheers

PhyberApex avatar Oct 05 '18 08:10 PhyberApex

@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.

joukevandermaas avatar Oct 05 '18 09:10 joukevandermaas

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

PhyberApex avatar Oct 05 '18 09:10 PhyberApex

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.

joukevandermaas avatar Oct 05 '18 10:10 joukevandermaas

Just so I understand you correctly. This would mean I could not do a "or" filter on multiple strings containing "," is this correct?

~Cheers

PhyberApex avatar Oct 05 '18 10:10 PhyberApex

It would be like ?filter[prop]="a,b","b,c", I think.

joukevandermaas avatar Oct 05 '18 11:10 joukevandermaas

Okay I will probably take a look at this during this weekend. And open an PR when I'm ready.

~Cheers

PhyberApex avatar Oct 05 '18 11:10 PhyberApex

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 avatar Oct 06 '18 11:10 PhyberApex

@PhyberApex a PR with the first steps would be great, thanks! If I remember right, the filtering code is pretty complex.

joukevandermaas avatar Oct 08 '18 06:10 joukevandermaas

Done!

PhyberApex avatar Oct 09 '18 12:10 PhyberApex