-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat: Add like
sub-string filter
#1091
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1091 +/- ##
===========================================
+ Coverage 67.39% 67.51% +0.11%
===========================================
Files 178 180 +2
Lines 16635 16690 +55
===========================================
+ Hits 11211 11268 +57
+ Misses 4476 4475 -1
+ Partials 948 947 -1
|
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.
Thanks for this clean implementation, was a nice review.
The "like" matching pattern I am assuming was motivated by SQL string matching operator that works with WHERE
? In that case is there any planned future work to fully support all the feature set of the like operator or do we want to do it within this PR?
The like operator has these functionalities:
str%
= match any value that starts with "str".%str
= match any value that ends with "str".%str%
= match any value that has "str" in any position.s%tr
= match any value that starts with "s" and ends with "tr"._s%
= match any value that have "s" in the second position.s_%
= match any value that starts "s" and is at least 2 characters in length.s__%
= match any value that starts "s" and is at least 3 characters in length (and so on).
This PR implements [1-3] only, IMO (4) might be worth having too.
IMO we should in future still implement regex search similar to how mongodb does it, as %
is essentially just the .*
pattern and _
is the ?
pattern. https://www.mongodb.com/docs/manual/reference/operator/query/regex/
I would change the PR title to something indicating that it is a like
substring filtering.
i.e. feat: Add ability to filter sub-strings using 'like'
I thought about this for a little bit. I think I prefer to have a simple like/nlike as we have in this PR (without worrying about I still am not sure how I feel about nlike lol - it feels odd, and I dislike extra operators, but we have no |
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.
Prod code looks good, would like to wait and see what people think RE the feature itself though before merge, and maybe an extra test or two on nil props
c6bcca3
to
fc5f4f6
Compare
No one specifically asked for it but I've often been in situations where I needed to find items that did not include a certain string. For example at my previous job I had to look for wireless product that had 5G in the name but not LTE. Also, pretty much all our other operators have the @shahzadlone |
like
sub-string filter
I think that is a decent middle ground. I'd be happy with the implementation of (4): =D |
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.
Looks good to me - thanks for expanding the tests (and for covering so much prior to the extra request)
9de3cf0
to
2db9a9a
Compare
I think once you implement (4) it's implementation might be a superset and handle (1), (2), (3) as well. Giving approval, it's okay if you want to do that in a separate pr, as the current code / features work. |
It's in this PR :) |
2db9a9a
to
cc9191c
Compare
Relevant issue(s) Resolves #982 Description This PR adds _like and _nlike filters to match on a sub-string basis. The % character can be used before and/or after the string to specify how the string should be matched. "String to match" will try to match the string exactly. It is equivalent to using the _eq filter. "%String to match" will match to a string ending with String to match. "String to match%" will match to a string starting with String to match. "%String to match%" will match to a string that contains String to match.
Relevant issue(s) Resolves sourcenetwork#982 Description This PR adds _like and _nlike filters to match on a sub-string basis. The % character can be used before and/or after the string to specify how the string should be matched. "String to match" will try to match the string exactly. It is equivalent to using the _eq filter. "%String to match" will match to a string ending with String to match. "String to match%" will match to a string starting with String to match. "%String to match%" will match to a string that contains String to match.
Relevant issue(s)
Resolves #982
Description
This PR adds
_like
and_nlike
filters to match on a sub-string basis. The%
character can be used before and/or after the string to specify how the string should be matched._eq
filter.String to match
.String to match
.String to match
.Tasks
unit and integration tests
(replace) Describe the tests performed to verify the changes. Provide instructions to reproduce them.
Specify the platform(s) on which this was tested: