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

Don't allow deleting saved forms that have created/updated entities #6311

Merged
merged 7 commits into from
Aug 12, 2024

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Aug 6, 2024

Closes #6012
Blocked by #6290

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

I considered a few different options here, but ultimately tracking this state in the instances DB seemed to make the most sense. Tracking it in forms, would mean blocking forms that can create/update entities but don't from deletion and tracking from entities would require a potentially very slow query.

I went with a boolean flag rather than storing the entity ID as we currently don't need that info, and I'd rather not do "foreign keys" between different DBs unless we need to.

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?

The biggest risk would be that we end up blocking deletion for forms that should be deletable. Checking that saved forms can/can't be deleted when expected is probably the best focus here.

Also, this involves migrating the instances DB so checking upgrades work correctly is important.

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

db.execSQL("CREATE TABLE IF NOT EXISTS " + INSTANCES_TABLE_NAME + " ("
+ _ID + " integer primary key autoincrement, "
+ DISPLAY_NAME + " text not null, "
+ SUBMISSION_URI + " text, "
+ CAN_EDIT_WHEN_COMPLETE + " text, "
+ CAN_DELETE_BEFORE_SEND + " text, "
Copy link
Member Author

Choose a reason for hiding this comment

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

I went with text here as that's what we use for CAN_EDIT_WHEN_COMPLETE, but I think it'd make more sense to store both of these as integer to save space (as SQLite doesn't have a boolean type). That feels like a change for another time though?

Copy link
Member

Choose a reason for hiding this comment

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

I don't have strong preferences here but if you want to change anything it's better do do that now to avoid testing db upgrades twice.

@seadowg seadowg marked this pull request as ready for review August 8, 2024 15:12
@grzesiek2010 grzesiek2010 merged commit 740f1a6 into getodk:master Aug 12, 2024
6 checks passed
@seadowg seadowg deleted the delete-instances branch August 12, 2024 14:34
@dbemke
Copy link

dbemke commented Aug 13, 2024

@seadowg Which version/versions of Collect should we use to check the upgrades?

@seadowg
Copy link
Member Author

seadowg commented Aug 13, 2024

@seadowg Which version/versions of Collect should we use to check the upgrades?

The store version works!

@dbemke
Copy link

dbemke commented Aug 13, 2024

The store version works!

We won't be able to upgrade the store (released version) version to the master (not released). We've got some apks from a previous PR from Grzegorz - it's 2024.3.0 beta 0 apk and 2024.2.1. And I've got apks of the master version made a few days ago. Which of these version would work best to test changes in entities?

@seadowg
Copy link
Member Author

seadowg commented Aug 13, 2024

We won't be able to upgrade the store (released version) version to the master (not released). We've got some apks from a previous PR from Grzegorz - it's 2024.3.0 beta 0 apk and 2024.2.1. And I've got apks of the master version made a few days ago. Which of these version would work best to test changes in entities?

When testing upgrading, we always want to use (at least) an APK for the last released version as that's what people will be upgrading from (not from master). I thought we'd talked about creating an archive of APKs for release versions that use the selfSignedRelease key. Did that not end up happening?

@dbemke
Copy link

dbemke commented Aug 13, 2024

I thought we'd talked about creating an archive of APKs for release versions that use the selfSignedRelease key. Did that not end up happening?

I think no one was assigned to do it. We (testers) assumed that either you or Grzegorz will create the apks cause we're not familliar with what happens just before creating the released version or when/ how to create the apks so they're the same as the released version. I'll add this topic to our weekly

@dbemke
Copy link

dbemke commented Aug 14, 2024

Sorry. I removed the label by accident cause I wanted to add "testing blocked" label but it doesn't exist.
We finished testing for now. We're blocked by issue #6338 because we can test deleting only finalized forms and we can reset forms. We prepared tests to for other cases which now we're not able to test because of the issue. It would be great if also issues #6304 #6336 were fixed so that we could check these forms too.

@WKobus
Copy link

WKobus commented Oct 10, 2024

Tested with Success

Verified on device with Android 14

Verified cases:

@dbemke
Copy link

dbemke commented Oct 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow entities to be deleted/cleared locally
4 participants