-
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 property eq expressions for entities #6351
Conversation
fa0819a
to
43b6bbc
Compare
#6336 crashes the app |
150e726
to
9b05aee
Compare
9b05aee
to
51d3999
Compare
).foldAndClose { | ||
mapCursorRowToEntity(list, it, it.getInt(ROW_ID)) | ||
} | ||
} else if (value == "") { |
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.
Can properties have blank values like " "
? Is it sanitized somewhere? I'm wondering if here we should use value.isBlank()
instead.
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.
This case only occurs if the property doesn't actually exist for the entities. It's the special case described above:
It's interestingly up for debate whether the behaviour for 2 is correct or not though in the case where thing is not a node that exists on the filtered nodes: JavaRosa would return all nodes, whereas Enketo would return none.
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.
This case only occurs if the property doesn't actually exist for the entities.
I see but isn't it somehow possible that it doesn't exist and the value here is not "" but " "?
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.
I see but isn't it somehow possible that it doesn't exist and the value here is not "" but " "?
Yes, but in that case we'd return an empty list because we'd be searching for nodes with a non-existent property equal to "something" rather than "nothing" and JavaRosa treats non-existent nodes as having the value ""
. Basically thing = ' '
is the same as thing = 'blah'
if thing
doesn't exist.
entities/src/main/java/org/odk/collect/entities/storage/InMemEntitiesRepository.kt
Show resolved
Hide resolved
collect_app/src/test/java/org/odk/collect/android/entities/EntitiesRepositoryTest.kt
Show resolved
Hide resolved
Tested with Success Verified on device with Android 14 Verified cases:
|
Tested with Success Verified on device with Android 10 |
Closes #6304
Closes #6314
Blocked by #6318Why is this the best possible solution? Were any other approaches considered?
There's two key fixes here:
thing = ''
expressions behave as they would in JavaRosa when they end up going throughgetAllByProperty
It's interestingly up for debate whether the behaviour for 2 is correct or not though in the case where
thing
is not a node that exists on the filtered nodes: JavaRosa would return all nodes, whereas Enketo would return none. It's likely that Enketo's behaviour is more correct here, but after discussing with @lognaturel we've decided to keep entities and JavaRosa evaluation consistent and then make all the ODK tools consistent later once web forms is dealing with secondary instances.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?
Firstly, because this PR makes changes to the entities DB but doesn't perform any migrations (as we haven't released the DB yet), the app should be uninstalled/reinstalled or data should be cleared before testing this.
Other than that, checking the bug is fixed and that entity forms (especially those with filtered selects) behave as expected is the most important thing.
Before submitting this PR, please make sure you have:
./gradlew connectedAndroidTest
(or./gradlew testLab
) and confirmed all checks still passDateFormatsTest