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

Fixed the filtering of duplicate columns #6543

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Dec 8, 2024

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

It turns out that properties might come in different order causing the problem that my tests didn't take into account, see:
https://github.com/getodk/collect/pull/6543/files#diff-c1535b2e1da246141cdc344e2d23e0ec8897df03e4055fd171a82a64cd0907a4R762

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?

Just continue testing that yu started in #6538.

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 marked this pull request as ready for review December 9, 2024 11:30
@grzesiek2010 grzesiek2010 requested a review from seadowg December 9, 2024 11:30
@grzesiek2010 grzesiek2010 added the high priority Should be looked at before other PRs/issues label Dec 9, 2024
@@ -757,5 +757,14 @@ abstract class EntitiesRepositoryTest {
savedEntities = repository.getEntities("things")
assertThat(savedEntities[0].properties.size, equalTo(1))
assertThat(savedEntities[0].properties[0].first, equalTo("prop"))

/**
* Attempt to save again to ensure that duplicate properties are correctly compared,
Copy link
Member

Choose a reason for hiding this comment

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

I think we can break this into two test now as it feels like we're accounting for two distinct (but very related cases):

  1. When an entity is created with duplicate case-insensitive properties
  2. When an entity is created with a new property that's a case-insensitive duplicate of an existing one.

So basically we can have one test that just checks saving something like:

val entity = Entity.New(
    "1",
    "One",
    properties = listOf(Pair("prop", "value"), Pair("Prop", "value"))
)

And another that checks saving a new entity to an existing list with a case-insensitive duplicate property like:

val repository = buildSubject()
val entity = Entity.New(
    "1",
    "One",
    properties = listOf(Pair("prop", "value"))
)

repository.save("things", entity)
var savedEntities = repository.getEntities("things")
assertThat(savedEntities[0].properties.size, equalTo(1))
assertThat(savedEntities[0].properties[0].first, equalTo("prop"))

repository.save("things", entity.copy(properties = listOf(Pair("Prop", "value"))))
savedEntities = repository.getEntities("things")
assertThat(savedEntities[0].properties.size, equalTo(1))
assertThat(savedEntities[0].properties[0].first, equalTo("prop"))

I'm pretty sure that'll drive out both the distintBy and the filterNot processing we have to do and give us different fails if one or the other is missing. Mainly though, I think it'll make it easier to understand the intended behaviour from the tests.

@seadowg seadowg merged commit b00460c into getodk:master Dec 9, 2024
6 checks passed
seadowg added a commit to seadowg/collect that referenced this pull request Dec 9, 2024
Fixed the filtering of duplicate columns
@seadowg seadowg mentioned this pull request Dec 9, 2024
6 tasks
@WKobus
Copy link

WKobus commented Dec 10, 2024

Tested with Success

Verified on device with Android 15

Verified cases:

  • Duplicate properties in entity registration form
  • Duplicate properties in entity update form

@dbemke
Copy link

dbemke commented Dec 10, 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
Labels
behavior verified high priority Should be looked at before other PRs/issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants