I am having this issue regarding empty database return with Room and RxJava Single. I know that my database is empty, so I am expecting to get an empty return when I trigger
@Query("SELECT * FROM Times WHERE timestamp = :timestamp")
fun getTimes(timestamp: String): Single<Times>
The problem is when I call this function as below
timeDao.getTimes("1398332113")
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.doOnError { Log.e("Single", "Returned null") }
.doOnSuccess { result -> times = result}
.subscribe()
The subscriber is indeed calling doOnError method like
E/Single: Returned null
but still returning an exception and crash
W/System.err: io.reactivex.exceptions.OnErrorNotImplementedException: Query returned empty result set: SELECT * FROM Times WHERE timestamp = ?
I have seen so many similar questions on StackOverflow, but couldn't find an answer. What am I am doing wrong?