Repository navigation
fix: the participant row is written without SQLite 3.24 - #502
Merged
Merged
Conversation
upsertParticipant wrote its row with INSERT ... ON CONFLICT DO UPDATE. That syntax arrived in SQLite 3.24 and Android 10 — the app's minimum — ships 3.22, where the statement is a syntax error. Every path that touches a person went through it: the startup migration, syncFromSystem, and creating a conversation. The visible symptom was a blank inbox: the import threw on the first new number, syncFromSystem logged its failure and no conversation was ever created, so a fresh install on Android 10 showed an empty app while the system still held the messages. The startup migration threw the same error from a coroutine, which took the whole process down. The write is now an UPDATE, then an INSERT when nothing matched, with the unique-constraint race caught and retried as an UPDATE. No statement needs anything newer than the platform's own SQLite, every column the old upsert kept is still written, and a non-phone sender still gets no participant row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
upsertParticipantwrote its row withINSERT … ON CONFLICT(…) DO UPDATE. That syntax arrived in SQLite 3.24, and Android 10 — the app's minimum SDK — ships 3.22, where the statement is a syntax error.Every path that touches a person went through it: the startup migration,
syncFromSystem(), and creating a conversation. The visible symptom on a fresh install ofDevelopon Android 10:RepoSync: syncFromSystem failed: android.database.sqlite.SQLiteException: near "ON": syntax error, and no conversation is ever created. That is the "blank screen".The fix
The write is now an
UPDATE, then anINSERTwhen nothing matched, with the unique-constraint race caught and retried as anUPDATE. No statement needs anything newer than the platform's own SQLite. Every column the old upsert kept is still written (normalized, send and display forms, comparable form, country code, sub id), and a non-phone sender still gets no participant row.Proof
Before, on the standing Android 10 AVD, after
pm clear:After, same clear and launch:
scripts/test-participant-upsert.sh(8 checks) — with the migration flag cleared and the table empty, the app launches, the table fills, a number stored without its+is normalised to E.164, the display form is written, no crash report is produced, and the pass marks itself done. Red on the pre-fix build (the app never came up), green after.JUnit:
ParticipantUpsertTest(3 tests) — no upsert syntax anywhere in the repository, the update-then-insert shape, every column, the concurrent-writer retry, and the migration's own flag.Full unit suite:
./gradlew testDebugUnitTest→ 1642 tests, 0 failures.Notes
DB_VERSION/DB_NAMEstayinternalrather thanprivate: the newer-database compatibility check reads them from another file.scriptssubmodule bumped to Messages-scriptsDevelop(9698429, pushed there first).