square / sqlbrite

A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operations.
https://square.github.io/sqlbrite/3.x/sqlbrite/
Apache License 2.0
4.57k stars 419 forks source link

mapToList do not emit item when result set is 0 row #233

Closed KpStP closed 6 years ago

KpStP commented 6 years ago

When result set is 0 row, mapToList method will not emit item. That mean the result set is empty at the beginning or non-empty result set change to empty, the method will not emit item too.

I want emit a empty array to trigger observer when result set is empty. If only want transform a single row query, that can use mapToOneOrDefault, but if want to transform a query to a list, there is no method to do this. I can solve the first case by using concat operator to combine empty array observable and query observable, look like this: Flowable.concat(emptyArrayFlowable, queryFlowable), but that can't solve the second case. Is there have approach to solve both case?

Thanks in advance.

JakeWharton commented 6 years ago

This test validates that an empty list is emitted when there are no rows: https://github.com/square/sqlbrite/blob/dae34762ca41f532094433c3ac1e515865e74754/sqlbrite/src/androidTest/java/com/squareup/sqlbrite3/QueryTest.java#L175-L180

If you think there is a bug, please create a failing test case.

KpStP commented 6 years ago

The problem cause by other place in my code. Sorry for my careless.