Skip to content

Fix foreign key crash when opening an unknown asset#373

Merged
gemcoder21 merged 1 commit into
mainfrom
fix-asset-market-fk-crash
May 22, 2026
Merged

Fix foreign key crash when opening an unknown asset#373
gemcoder21 merged 1 commit into
mainfrom
fix-asset-market-fk-crash

Conversation

@DRadmir
Copy link
Copy Markdown
Contributor

@DRadmir DRadmir commented May 22, 2026

Opening an asset that isn't in the wallet's local DB crashed with
SQLiteConstraintException: FOREIGN KEY constraint failed.

updateAssetMetadata ran Room @Update on the asset row — a no-op when
the row doesn't exist — then inserted asset_market referencing the
missing asset.

The fetched AssetFull is now persisted as one atomic aggregate: the
asset root is upserted first, then links and market in a single
@Transaction.

Closes #372

Opening an asset that is not in the wallet's local DB crashed with
SQLiteConstraintException: FOREIGN KEY constraint failed.

updateAssetMetadata used Room @update for the asset row, which is a
no-op when the row does not exist, then inserted asset_market with a
foreign key to the missing asset.

Persist the fetched AssetFull as one atomic aggregate: upsert the asset
root first, then links and market in a single @transaction.
@DRadmir DRadmir self-assigned this May 22, 2026
@gemcoder21 gemcoder21 merged commit 993fa7f into main May 22, 2026
3 checks passed
@gemcoder21 gemcoder21 deleted the fix-asset-market-fk-crash branch May 22, 2026 23:40
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.

FOREIGN KEY constraint failed

2 participants