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

fix: fixed lower case for "IN" operator in queryFilters [DHIS2-11770] #8724

Merged
merged 2 commits into from
Sep 15, 2021

Conversation

gnespolino
Copy link
Contributor

@gnespolino gnespolino commented Sep 14, 2021

When we introduced possibility to include null values in filters, we needed to threat "IN" operator in a different way. Infact the way the code is structured didn't allow to render SQL condition properly when IN included also a null value.
In cases such ";IN;Female:NV", SQL condition needs to be "field IN (female) or field is null".
In this case a proper InQueryFilter class was written to be able to render condition properly. However all the work to encode and quote parameters properly, which came out of the box for other operators, need to be handled inside InQueryFilter to be effective. This PR addresses a missing quoting and escaping which was introduced when InQueryFilter was written.

This should go into 2.37.

Adding @Philip-Larsen-Donnelly for approval.

Copy link
Contributor

@maikelarabori maikelarabori left a comment

Choose a reason for hiding this comment

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

Looks good @gnespolino 👍

Thanks

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@@ -63,13 +65,16 @@ public InQueryFilter( String field, QueryFilter queryFilter )
* @param encodedFilter actual "in" parameters
* @return a SQL condition representing this InQueryFilter
*/
public String getSqlFilter( String encodedFilter )
public String getSqlFilter( String encodedFilter, boolean isText )
Copy link
Member

@larshelge larshelge Sep 15, 2021

Choose a reason for hiding this comment

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

Please add a description to explain the initial problem and why this fixes it :-) My understanding is we already quote event analytics query filters but I might be wrong.

@stian-sandvold stian-sandvold merged commit 5bfbec8 into master Sep 15, 2021
@stian-sandvold stian-sandvold deleted the DHIS2-11770_IN_operator_fix branch September 15, 2021 08:26
@larshelge
Copy link
Member

Looks good @gnespolino ! Thanks for the explanation/description.

@larshelge
Copy link
Member

I think we could have added a few unit tests here, especially InQueryFilter should be feasible to unit test.

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.

4 participants