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

Filter out case-insensitive duplicate properties #6503

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Nov 8, 2024

Closes #6501

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

The real issue here is that SQLite is case-insensitive, so attempting to add columns with names like col and Col results in an exception. I don't think we need to implement any special handling for this, as it doesn't make much sense to add such properties in the first place. Therefore, I believe filtering out duplicates is a good solution.

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?

It should be enough to test entities with duplicate properties like col and Col.

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

No.

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

@grzesiek2010 grzesiek2010 changed the title Collect 6501 Filter out case-insensitive duplicate properties Nov 8, 2024
@@ -36,4 +37,19 @@ class DatabaseEntitiesRepositoryTest : EntitiesRepositoryTest() {
repository.save("things", savedEntity)
assertThat(repository.getEntities("things")[0], sameEntityAs(savedEntity))
}

@Test
fun `#save ignores case-insensitive duplicate properties`() {
Copy link
Member

Choose a reason for hiding this comment

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

From the conversation on Slack, it looks like we want this to be a feature of entities in general, so I think this should move to EntitiesRepostitoryTest.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@seadowg
Copy link
Member

seadowg commented Nov 11, 2024

Marking this as "needs testing" early as the requested changes are just for tests.

@lognaturel
Copy link
Member

In that Slack conversation, I had some questions about whether we should do this at all given how surprising the outcome is.

I think our only real alternative would be to throw an exception when processing. The advantage of an exception is that it would at least tell the user that something unexpected happened. But given that we're very likely going to address the issue on the server side, this case would only be for other hypothetical servers. Let's go with it.

@grzesiek2010 grzesiek2010 requested a review from seadowg November 15, 2024 20:32
@seadowg seadowg merged commit 3f48164 into getodk:master Nov 18, 2024
6 checks passed
@WKobus
Copy link

WKobus commented Nov 19, 2024

Tested with Success

Verified on device with Android 15

Verified cases:

  • Adding different entity properties by "+new" button
  • Adding different entity properties by uploading form with new properties

@dbemke
Copy link

dbemke commented Nov 19, 2024

Tested with Success

Verified on device with Android 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash processing Entity List when there are Entity properties with names that are identical except for case
5 participants