Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search filter for null values #70

Closed
theofidry opened this issue May 21, 2015 · 6 comments
Closed

Search filter for null values #70

theofidry opened this issue May 21, 2015 · 6 comments

Comments

@theofidry
Copy link
Contributor

One request often made when filtering a collection by values is the case of the null value. Sadly this is a very painful case because the value retrieved on the server side is always a string and that it's no possible with the current implementation to pass an empty value.

Unfortunately I didn't find much on the subject aside from this post which suggest a "hacky" solution: defining custom values.

I tested a little bit with a StrongLoop application and the following query ?filter[where][property]=null works whatever the type of the value is.

The only problem is for string values. Indeed it becomes impossible to search for a string with the value "null".

@dunglas, @sroze what are your though on this case? Should we do as StrongLoop which has the drawback of disabling the search filter for string properties of value "null"?

@dunglas
Copy link
Member

dunglas commented May 22, 2015

There is only one proper way to handle such case. Using the explicit representation of Hydra: http://www.hydra-cg.com/spec/latest/core/#h-templated-links

Currently we only support BasicRepresentation. Work on that is welcome. An other way to handle such edge cases for now is using custom filters.

@blaues0cke
Copy link

Here is a custom filter doing this: https://gist.github.com/blaues0cke/e45a56f32439d8882390

Use it like this: ?property-name-empty=true

@theofidry
Copy link
Contributor Author

Thanks @blaues0cke, I've rolled out mine since then ;) It was more a question of merging it back to the bundle or not.

@blaues0cke
Copy link

@theofidry Yeah, just landed in this issue after some research and wanted to share our solution with the next person that ends up here. :-)

@nicholasruunu
Copy link

nicholasruunu commented Feb 21, 2017

In the same spirit as @blaues0cke I'll share our solution inspired by range filter:
?property[null]=true/false

https://gist.github.com/nicholasruunu/db1d840bebe4dd6de3ba20ac776dcf41

@teohhanhui
Copy link
Contributor

teohhanhui commented Feb 21, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants