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 handling of numbers in SQLite query arguments #6619

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Feb 20, 2025

Closes #6617

Why is this the best possible solution? Were any other approaches considered?

When filters include numeric values like age=25, JavaRosa represents the number as a Double (25.0). However, SQLite requires arguments to be strings. To ensure correct comparisons in the database, we need to check if the Double value has a .0 fractional part. If it does, we should first convert it to an Int and then to a String, resulting in 25 instead of 25.0. This prevents issues caused by the redundant decimal part during value comparisons.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

We need to test filters with numbers like age=25. The form that is attached to the issue contains such a filter and that was the cause of the crash.

Do we need any specific form for testing your changes? If so, please attach one.

The from that is attached to the issue can be used.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

@@ -87,7 +87,13 @@ class LocalEntitiesFilterStrategy(entitiesRepository: EntitiesRepository) :

return if (candidate != null) {
val child = candidate.nodeSide.steps[0].name.name
val value = candidate.evalContextSide(sourceInstance, evaluationContext) as String
var value = candidate.evalContextSide(sourceInstance, evaluationContext)
Copy link
Member

Choose a reason for hiding this comment

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

Where does the type of value come from? Could it also be any other type like maybe a date type or boolean?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the filter it is just a number like age=25 but JR keeps numbers as doubles so it is 25.0. Before converting it to string we need to get rid of that .0 which I described above.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could it also be any other type like maybe

Yes I was thinking about dates as well. I'm going to check that.

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks. My recollection is that this was addressed for the simple expression case. I would have expected the same tests related to that to catch this. Is there branching between the simple expression and complex expression (with and/or) case? Am I remembering incorrectly about those tests?

Copy link
Member

Choose a reason for hiding this comment

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

My recollection is that this was addressed for the simple expression case. I would have expected the same tests related to that to catch this. Is there branching between the simple expression and complex expression (with and/or) case? Am I remembering incorrectly about those tests?

It's not clear to me what you're referring to here @lognaturel. What's the simple expression case?

@grzesiek2010 grzesiek2010 requested a review from seadowg February 20, 2025 20:20
@grzesiek2010 grzesiek2010 marked this pull request as ready for review February 20, 2025 20:20
@grzesiek2010 grzesiek2010 added the high priority Should be looked at before other PRs/issues label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority Should be looked at before other PRs/issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash during filling filter choice expressions form
3 participants