-
-
Notifications
You must be signed in to change notification settings - Fork 419
PICARD-2486: Add text-based comparison script functions #2110
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
PICARD-2486: Add text-based comparison script functions #2110
Conversation
For the sake of completeness, should there also be integer-based |
I'm a bit bothered by introduction of another full set of new comparison functions for text and I wonder if we should handle text type in existing comparison functions instead. What I'm thinking about is something like:
|
Reduce code redundancy using an helper function and operator module
In a related PR @zas commented: I wonder if we could extend this to eq(), ne() and not(). (Copied here to keep the discussion in one place.) |
We could, but it might be a bit odd because (as you pointed out in IRC) the default processing type is different for these functions. |
I agree that another set of functions becomes difficult. And as a user I'd really expect this to do the right thing. Maybe we could even do an |
That sounds like a good idea. I can take a look at adding that. Should "auto" become the default? Even though this new default would be different, I don't think it would break any scripts. |
- Change `ncase` type to `nocase` for consistency between functions - Add `auto` type to auto select between `int`, `float` and `text`
0b839b5
to
724793c
Compare
I've implemented the Also, there are two different text comparison types available: |
3266332
to
9988351
Compare
Summary
Problem
The current scripting comparison functions
$gt()
,$gte()
,$lt()
and$lte()
operate on interger values only. This does not support things like date comparisons. See the discussion at https://community.metabrainz.org/t/how-set-date-to-minimum-of-recording-firstreleasedate-and-originaldate/585648 and https://community.metabrainz.org/t/feature-request-numeric-functions-min-and-max-in-picards-scripting-language/585669 for more information.Solution
Adds four new text-based comparison scripting functions$textlt()
,$textlte()
,$textgt()
and$textgte()
, plus text-based$textmin()
and$textmax()
functions.Adds an optional argument to the existing
$lt()
,$lte()
,$gt()
and$gte()
functions to specify whether the arguments should be processed as int, float, text (case-sensitive text) or nocase (case-insensitive text). If no argument is provided the comparison will be processed as int to maintain backward compatibility.Also adds two new functions
$min()
and$max()
, with the type of processing specified as one of int, float or text (case-sensitive text) as the first argument.Action
I assume that, if accepted, these changes would be applied to Picard v3.0 (or v2.9 if there is such a release). If accepted for other than v3.0 then the function description docstrings will need to be updated accordingly.
I wasn't sure which branch to merge into, so I used the
master
branch. We can change the target if necessary.If accepted, the Picard documentation will need to be updated.