-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: master
Are you sure you want to change the base?
Conversation
@@ -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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
entities/src/main/java/org/odk/collect/entities/javarosa/filter/LocalEntitiesFilterStrategy.kt
Outdated
Show resolved
Hide resolved
05fc3fe
to
8339251
Compare
8339251
to
bab2345
Compare
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 in25
instead of25.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:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest