-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Added/fixed a filtering option "contains string" for String fields. #724
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
Conversation
…ase insensitive for now.
Thanks for your PR, @ssamuli. I left one small note. |
src/lib/queryFromFilters.js
Outdated
@@ -60,6 +60,8 @@ function addConstraint(query, filter) { | |||
query.greaterThan(filter.get('field'), filter.get('compareTo')); | |||
break; | |||
case 'containsString': | |||
query.matches(filter.get('field'), filter.get('compareTo'), 'i'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation in Parse.query states only two parameters: key and regex. What's the 'i'
string you pass here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its an undocumented "modifiers" parameter to "matches" function of ParseQuery, 'i' means case insensitive: https://github.com/parse-community/Parse-SDK-JS/blob/master/src/ParseQuery.js#L714
In retrospect, looking at the ParseQuery code, it seems to be possible to pass 'case insensitive' inside the second parameter (regex) too.
Is there something you'd like me to change or add to this feature to facilitate the merging process? |
One last question I have before merging, as I was working on something very similar (allowing to filter if a pointer exists or not): before your changes, both |
You are correct, it was not activated in Filters.js. Also the query was not correct because it fell through to Maybe to make things more clear and not change how the query behaves with arrays (although this seems to work with them too), I should add a new |
…void changing how array queries work.
Should be better and safer like this. Didn't think of the array query much when I initially sent the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I think it's better!
Thanks, @ssamuli !
Also, @ssamuli, I was trying recently to do something to fix #720 . Initially, we could add at least an option to have exists and does not exist for objects - that's currently not available and works out of the box with the current What do you say? Could you help us with this? |
Thanks! Looks like that's something I can help with. |
Bear in mind that you should use dot notation for this: |
@natanrolnik OK, here it is: #727 |
There are options "startsWith" and "endsWith" in the filter input for string fields, but "contains string" option is for some reason missing, so I made this change. In my opinion it is pretty important feature for people who use dashboard to browse their parse data.
It does filtering case insensitively for now. Could maybe add later a checkbox for selecting case sensitivity.