Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed deleting entities from lists with special characters #6561

Merged
merged 4 commits into from
Jan 16, 2025

Conversation

grzesiek2010
Copy link
Member

@grzesiek2010 grzesiek2010 commented Jan 13, 2025

Closes #6559

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

We need to quote the list name to make it possible to use special characters in table names in SQL. It's not the first issue like that so this approach is the same as it was before in the case of similar problems.

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’ve encountered issues with handling special characters in entities in other areas before, so this isn’t a new problem. Please test it as described in the issue (deleting entities), but keep in mind that this might not be the last case we’ll need to address.

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

Any form with entities where lists contain special characters like . or -.

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 requested a review from seadowg January 13, 2025 17:34
@grzesiek2010 grzesiek2010 marked this pull request as ready for review January 13, 2025 17:34
Copy link
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

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

This should target v2024.3.x instead of master as we want to put it out as a hotfix.

@grzesiek2010 grzesiek2010 changed the base branch from master to v2024.3.x January 14, 2025 12:25
@grzesiek2010 grzesiek2010 requested a review from seadowg January 14, 2025 12:26
@grzesiek2010
Copy link
Member Author

This should target v2024.3.x instead of master as we want to put it out as a hotfix.

Fixed.

repository.save("wines.x", leoville)
repository.save("wines-x", leoville)

repository.delete("1")
Copy link
Member

Choose a reason for hiding this comment

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

This makes me realize that delete should probably take a list as an arg as well, but that's for another time!

Copy link
Member Author

Choose a reason for hiding this comment

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

Right: #6566

@@ -198,7 +198,7 @@ class DatabaseEntitiesRepository(context: Context, dbPath: String) : EntitiesRep
databaseConnection.withConnection {
getLists().forEach {
writableDatabase.delete(
it,
"`$it`",
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to use backticks here instead of quotes like in the rest of the file?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it looks like we can use both.

Copy link
Member

Choose a reason for hiding this comment

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

Ok let's make it consistent. Maybe we should introduce a quote method?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh weird I said: No, it looks like we can use both. and at the same time made it consistent but it looks like I didn't push the changes...

@grzesiek2010 grzesiek2010 requested a review from seadowg January 15, 2025 18:20
Copy link
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

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

@grzesiek2010 grzesiek2010 requested a review from seadowg January 16, 2025 13:41
@seadowg seadowg merged commit 8c76211 into getodk:v2024.3.x Jan 16, 2025
6 checks passed
@seadowg seadowg added the high priority Should be looked at before other PRs/issues label Jan 16, 2025
@dbemke
Copy link

dbemke commented Jan 20, 2025

Tested with Success!

Verified on a device with Android 10 and 12 (by Szymon)

Verified cases:

@WKobus
Copy link

WKobus commented Jan 20, 2025

Tested with Success

Verified on device with Android 15

seadowg added a commit to seadowg/collect that referenced this pull request Jan 22, 2025
Fixed deleting entities from lists with special characters
# for free to join this conversation on GitHub. Already have an account? # 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.

Crash when updating entities for list with special characters
4 participants