-
Notifications
You must be signed in to change notification settings - Fork 326
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
Handle Nothing
values in Filter_Condition.to_predicate
#8600
Handle Nothing
values in Filter_Condition.to_predicate
#8600
Conversation
Equal_Ignore_Case value locale -> | ||
handle_nothing <| txt-> (txt : Text).equals_ignore_case value locale | ||
Starts_With prefix case_sensitivity -> | ||
handle_nothing <| txt-> (txt : Text).starts_with prefix case_sensitivity | ||
Ends_With suffix case_sensitivity -> | ||
handle_nothing <| txt-> (txt : Text).ends_with suffix case_sensitivity | ||
Contains substring case_sensitivity -> | ||
handle_nothing <| txt-> (txt : Text).contains substring case_sensitivity | ||
Not_Contains substring case_sensitivity -> | ||
handle_nothing <| txt-> (txt : Text).contains substring case_sensitivity . not |
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.
I added the txt:Text
checks, because I think that Expected txt to be Text, but got [...].
will be more readable than e.g. Method
.equals_ignore_case of type [...] could not be found.
.
txtvec = alter ["abab", "baaa", Nothing, "cccc", "BAAA"] | ||
txtvec.filter (Filter_Condition.Equal_Ignore_Case "baaA") . should_equal ["baaa", "BAAA"] | ||
txtvec.filter (Filter_Condition.Contains "a") . should_equal ["abab", "baaa"] | ||
txtvec.filter (Filter_Condition.Starts_With "a") . should_equal ["abab"] | ||
txtvec.filter (Filter_Condition.Ends_With "a") . should_equal ["baaa"] | ||
txtvec.filter (Filter_Condition.Like "b%a") . should_equal ["baaa"] | ||
# Nothing is not included in the negation either | ||
txtvec.filter (Filter_Condition.Not_Like "b%a") . should_equal ["abab", "cccc", "BAAA"] |
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.
Note, here we 'break' the property that
forall v p,
(v.filter (Filter_Condition.Like p)) + (v.filter (Filter_Condition.Not_Like p)) . length == v.length
because the Nothing
values do not get into either category.
I think that is OK, because Like
and Not_Like
are both Text filters that return _Text_s that satisfy a condition, Nothing
is neither like nor not-like a pattern.
Do you think that is OK?
I'm also fine with including Nothing
in the Not_Like
case if that is preferred.
75d638e
to
31136bd
Compare
31136bd
to
88a5da6
Compare
Pull Request Description
Vector.filter
byFilter_Condition
does not work well withNothing
#8549Type_Error
is thrown instead of aNo_Such_Method
error on type mismatches.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.