Fix backend↔DB sync for sessions & maps - #191
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Clear shapes/pictograms for the event before re-inserting, so surviving maps no longer accumulate duplicates and the Map REPLACE no longer trips a foreign-key violation against stale children. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…nt sessions Rebuild SessionCategory/Format/Tag and speaker links for sessions in the response, delete child rows before parents in clean(), wire up Tag/EventSession/Schedule diff-deletes, and drop the misdirected diffSessions/deleteSessions duplicates. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Summary
The agenda/maps sync already used an "upsert + diff-delete" pattern, but the delete half was incomplete. Combined with enforced foreign keys, that produced three symptoms: stale data not removed, sync silently doing nothing, and duplicated map shapes/pictograms.
Root cause: when the backend dropped a referenced parent (category/format/tag/speaker),
clean()deleted it while a stale junction row still pointed at it →SQLITE_CONSTRAINT_FOREIGNKEY→ the swallowingcatchinfetchAndStoreAgendarolled back the whole transaction. So "stale data not removed" and "sync does nothing" were the same bug.This PR completes the cleanup and makes deletion FK-safe:
MapREPLACE itself tripped an FK once children existed).SessionCategory/SessionFormat/SessionTagand speaker links for the response's sessions, delete child/junction rows before parents inclean(), wire up the unusedTagdelete, add realEventSession/Schedulediff-deletes, and drop the misdirecteddiffSessions/deleteSessionsduplicates.TalkSessionnow uses anINSERT OR IGNORE … UPDATEupsert (likeCategory/Format) sois_favoritesurvives a sync instead of being reset tofalsebyINSERT OR REPLACE.fetchAndStoreAgendanow logs the event id on failure (catch kept by design).desktopTest, FK enforcement on) covering duplication, idempotent re-sync, category reassignment without FK crash, favorite preservation, and removal of stale rows.Test Plan
./gradlew :shared:core:desktopTest— 20 tests, 0 failures./gradlew ktlintCheck detekt— clean./gradlew lintDebug— clean🤖 Generated with Claude Code