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

feat: contains and containsItems [DHIS2-16211] #50

Closed
wants to merge 1 commit into from

Conversation

jimgrace
Copy link
Member

@jimgrace jimgrace commented Mar 3, 2024

This PR adds two expression functions:

contains(expr, ...) returns true if the first expr contains each of the following expressions as a substring.

containsItems(expr, ...) returns true if the first expr is split into tokens separated by commas, and each of the following expressions exactly matches one of the tokens.

See DHIS2-16211 for more details and examples.

@jbee Note that in ExpressionGrammar.kt the grammar is defined as:

        fn(NamedFunction.contains, expr, expr, expr.plus()),
        fn(NamedFunction.containsItems, expr, expr, expr.plus()),

I wanted to require two expression arguments and then have optional additional expressions. But this seemed to result in no expressions required, essentially the equivalent of:

        fn(NamedFunction.contains, expr.plus()),
        fn(NamedFunction.containsItems, expr.plus()),

As a result, these functions can be called with no arguments. Then when ExpressionFunctions contains(values: List<String?>) and containsItems(values: List<String?>) refer to values[0] they generate an IndexOutOfBoundsException, as is tested for in ContainsTest and ContainsItemsTest. I did not try to fix this because I didn't know how you would want to address the problem.

@vgarciabnz vgarciabnz changed the base branch from main to beta March 4, 2024 07:33
@vgarciabnz
Copy link
Member

@jimgrace @jbee I have changed the base branch to beta just to trigger a beta build instead of a production build (there is no production release yet for the mulitplatform library).

Copy link
Collaborator

@jbee jbee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see the mistake with the function, I will update the PR

@jbee
Copy link
Collaborator

jbee commented Mar 4, 2024

Closing if favor of #51 (I did not find how to make a PR to your PR without needing write access to your fork so I made a new PR)

@jbee jbee closed this Mar 4, 2024
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

Successfully merging this pull request may close these issues.

3 participants