Blaž Vantur
10/30/2024, 6:05 PMRoom 2.7.0-alpha11
in my KMP project.
I am reading my database data with the next query:
@Query("SELECT * FROM ${Event.TABLE_NAME}")
fun getAllEvents(): Flow<List<EventEntity>>
And I have a Query for removing the item like this:
@Query("DELETE FROM ${Event.TABLE_NAME} WHERE ${Event.COLUMN_ID} == :id")
suspend fun removeById(id: String)
In a case when removeById is called as a single method without transaction, item gets successfully removed and query that reads all items from database return update List of Event items. But if removal is done within transaction, the item is also successfully removed, but it is not detected by Flow.
So next block is not working for me:
database.useWriterConnection {
it.immediateTransaction {
eventEntity = database.getEventDao().getEventById(id)
database.getEventDao().removeById(id)
database.getAttendeeDao().removeByEventId(id)
}
}
What could be the reason for that? Any ideas? Maybe I am missing some Room based annotations on my Dao methods?danysantiago
11/04/2024, 3:30 PMinvalidationTracker.refreshAsync()
after you are done with the connection to trigger invalidation since Room doesn't know well what was done during the transaction (could have been all read operations).Blaž Vantur
11/05/2024, 8:41 AM