I have an SQL query that selects all items where two of the fields are NULL.
My repository looks like this:
override suspend fun flowTeamsWithNoGroupByGameId(gameId: Int): Flow<List<Team>> {
return transactionQueries
.selectAllTeamsWithNoDesignatedGroupByGameId(gameId.toLong())
.asFlow()
.mapToList()
.map { queryResult ->
queryResult.map {
Team(
teamId = it.id ?: "",
name = it.name ?: "",
federation = it.federationId ?: 0,
latitude = it.latitude ?: 0.0,
longitude = it.longitude ?: 0.0
)
}
}
}
My ViewModel:
viewModelScope.launch(Dispatchers.IO) {
launch {
repository.flowTeamsWithNoGroupByGameId(TEMP_GAME_ID).collect {
Log.d(LOG_TAG, "teams collected $it")
_allTeams.value = it
}
}
}
The code basically loads a list of teams. The teams are displayed when the screen is opened successfully. However, when an update is made on the database through the app, the list doesn't reflect the changes (I verified the table is updated).
The log shows that it doesn't collect the new values.
When I use the App Inspection tool to make changes on the database manually, the log shows that it collects the values.
So, I'm confused why is this happening?
Any ideas or explanation? I will appreciate it!