Hello, im having an issue with Kotlin Flow and Roo...
# android
c
Hello, im having an issue with Kotlin Flow and Room. Im trying to return a Flow of a Tupple data class(https://developer.android.com/training/data-storage/room/accessing-data#query-subset-cols). But the compiler throw this error:
Copy code
WalletDao.java:11: error: Not sure how to convert a Cursor to this method's return type
Has someone experienced something like this?
g
Could you show how you define your DAO interface
c
Sure
Copy code
@Query("""
    SELECT w.name, w.category_id, w.currency_id, w.amount_now,
    COUNT(money.id) AS movements
    FROM wallet w
    LEFT JOIN money ON w.id = money.parent_id
    WHERE w.id=:walletId
    """)
suspend fun get(walletId: Long): Flow<WalletInformationTuple>
Thats it
g
Remove suspend
🙈 1
you cannot have suspend + Flow at the same time, and it itself doesn’t make sense, you receive updates when collecting flow, there is no reason to suspend to get this flow
👍 3
c
Andrey Man... Thank you! hahaha I didn't saw the
suspend
there.
a
I think If we get a warning then might be helpful here.
g
Error message actually has sense there, it says that there is no adapter for type
Flow
as return type, the same error message which you receive for any other unknown type as return value. Of course it may be some special error message just for this case, but it looks a bit artificial. Tho, it may be an IDE lint warning