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

DHIS-16705 Fix handling of NV filter clause #19758

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

luciano-fiandesio
Copy link
Contributor

  • Fix reference to table alias in PI CTE
  • Fix quoting of sort order column

operator = "is not";
} else {
throw new IllegalQueryException(
ErrorCode.E3000,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should use a dedicated error code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Argh, you are right, fixing it

String operator = "NULL".equals(value) ? "is" : filter.getSqlOperator();
String operator = filter.getSqlOperator();

if (value.trim().equalsIgnoreCase("null")) {
Copy link
Member

@larshelge larshelge Jan 23, 2025

Choose a reason for hiding this comment

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

I think we could find a way to make this a bit more compact/encapsulated. We could move "null" to a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I can refactor it to be more compact and readable. Do we have constants for null somewhere? I am sure there must be but hard to find the constant

Copy link
Member

@larshelge larshelge Jan 23, 2025

Choose a reason for hiding this comment

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

Great. Right. I guess there is AnalyticsConstants where we could add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok,done

if (value.trim().equalsIgnoreCase("null")) {
if (filter.getOperator() == QueryOperator.EQ || filter.getOperator() == QueryOperator.IEQ) {
operator = "is";
} else if (filter.getOperator() == QueryOperator.NEQ
Copy link
Member

Choose a reason for hiding this comment

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

There is now a method in master isNotEqualTo() for QueryOperator which we can use here.

https://github.com/dhis2/dhis2-core/blob/master/dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryOperator.java#L101

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah nice

@luciano-fiandesio luciano-fiandesio added run-api-analytics-tests Enables analytics e2e tests and removed run-api-analytics-tests Enables analytics e2e tests labels Jan 23, 2025
@luciano-fiandesio luciano-fiandesio merged commit 237752e into master Jan 23, 2025
20 of 22 checks passed
@luciano-fiandesio luciano-fiandesio deleted the DHIS-16705_FIX_FILTERING branch January 23, 2025 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-api-analytics-tests Enables analytics e2e tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants