Skip to content

Fix catalogue re-import deleting tastings and reverting edits - #24

Merged
T0liver merged 1 commit into
mainfrom
c-catalog-import-ignore-fb6c
Nov 21, 2026
Merged

T0liver merged 1 commit into
mainfrom
c-catalog-import-ignore-fb6c

Conversation

@T0liver

@T0liver T0liver commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Fixes #17

Cause

WineDao.insertAll used OnConflictStrategy.REPLACE, which deletes and re-inserts an existing wine row on catalogue re-import. TasteEntity references wines with onDelete = CASCADE, so every re-import wiped tastings for catalogue wines and replaced user-edited fields with catalogue data.

Fix

  • Switch bulk catalogue inserts to OnConflictStrategy.IGNORE so existing rows (and their tastings) are left intact and user edits are not overwritten on full re-import or file import.
  • Route delta catalogue updates through WineDao.updateAll / WineRepository.updateAll so corrected catalogue fields apply with an in-place UPDATE instead of delete-and-reinsert.
  • Add CatalogImportPreservesDataTest (instrumented Room test) covering re-import after a user edit and a recorded tasting.

Verification

  • ./gradlew assembleDebug compileDebugAndroidTestKotlin — BUILD SUCCESSFUL
Open in Web Open in Cursor 

Use OnConflictStrategy.IGNORE for bulk catalogue inserts so existing wine
rows are not deleted and re-created (which CASCADE-deleted tastings).
Apply delta catalogue updates with Room @update instead of REPLACE insert.
Add instrumented DAO test for re-import preserving tastings and user edits.

Co-authored-by: T0liver <T0liver@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

Test Results

1 tests  ±0   1 ✅ ±0   0s ⏱️ ±0s
1 suites ±0   0 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit 0f5174e. ± Comparison against base commit c865cc7.

@T0liver
T0liver merged commit 23d33fb into main Nov 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Automated test] Catalogue import deletes tastings and overwrites edits on catalogue wines

2 participants