Fix Room SQL parser errors in Web3WalletDao/Web3AddressDao#6049
Fix Room SQL parser errors in Web3WalletDao/Web3AddressDao#6049SeniorZhai wants to merge 5 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes Room SQL parser errors in Web3WalletDao and Web3AddressDao by refactoring how UNION queries are constructed. The changes eliminate the use of a companion object constant (WALLET_ITEM_QUERY) that was causing Room's SQL parser to fail, and instead inline the full SQL queries directly in each @Query annotation.
Key Changes
- Removed the
WALLET_ITEM_QUERYcompanion object constant fromWeb3WalletDaoand inlined its SQL in all queries that used it - Split
getWalletByAddressintogetSafeWalletByAddressto be more explicit about querying only safe wallets - Added
@SuppressWarnings(RoomWarnings.QUERY_MISMATCH)annotations toWeb3TokenDaomethods to suppress expected warnings from LEFT JOIN queries
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Web3WalletDao.kt | Removed companion object and inlined UNION queries for wallet retrieval across wallets and safe_wallets tables |
| Web3AddressDao.kt | Refactored queries to avoid companion object reference; split getWalletByAddress into more explicit getSafeWalletByAddress method |
| Web3Repository.kt | Renamed getWalletByAddress to getSafeWalletByAddress to match DAO layer changes |
| SessionRequestViewModel.kt | Updated method call to use renamed getSafeWalletByAddress |
| Web3ViewModel.kt | Updated method call to use renamed getSafeWalletByAddress |
| Web3TokenDao.kt | Added query mismatch suppressions for LEFT JOIN queries that intentionally return extra columns |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| suspend fun getWalletByDestination(destination: String): WalletItem? // Only find with wallets | ||
|
|
||
| @Query( | ||
| """ | ||
| SELECT wallet_id AS id, 'mixin_safe' AS category, name, created_at AS createdAt, updated_at AS updatedAt, | ||
| role AS safeRole, chain_id AS safeChainId, address AS safeAddress, url AS safeUrl | ||
| FROM safe_wallets | ||
| WHERE address = :destination AND chain_id = :chainId | ||
| LIMIT 1 | ||
| """, | ||
| ) | ||
| suspend fun getSafeWalletByAddress(destination: String, chainId: String): WalletItem? // Only find with safe_wallets |
There was a problem hiding this comment.
The inline comments "Only find with wallets" and "Only find with safe_wallets" describe implementation details rather than the purpose or usage of these methods. Consider updating these comments to describe when each method should be used or what scenarios they handle, which would be more helpful for API consumers.
# Conflicts: # app/src/sharedTest/java/one.mixin.android.mock/AccountMock.kt
No description provided.