我有一个项目,我有一个用于SQLite的DBFlow库。
当我尝试从表中删除一些数据时,会出现问题。
override fun removeOldEventPlanners(): Single<Boolean> {
LogMgr.v(TAG, "removeOldEventPlanners()")
return Single.create { emitter ->
RXSQLite.rx(SQLite.delete().from(EventPlanner::class.java)
.where(EventPlanner_Table.date_to.lessThan(Date(TimeUtil.getCurrentTime().time - CONST_30_DAYS_IN_MILLISECONDS)))
.or(EventPlanner_Table.deleted.`is`(1)))
.queryList()
.subscribe({ eventPlanners ->
LogMgr.d(TAG, "removeOldEventPlanners queryList() $eventPlanners")
emitter.onSuccess(true)
}, { throwable ->
LogMgr.e(TAG, "removeOldEventPlanners error", throwable)
emitter.onError(throwable)
})
}
}
此代码引发异常:
java.lang.IllegalArgumentException: Please use query(). The beginning is not a ISelect
at com.raizlabs.android.dbflow.sql.language.Where.checkSelect(Where.java:259)
at com.raizlabs.android.dbflow.sql.language.Where.queryList(Where.java:235)
at com.raizlabs.android.dbflow.rx2.language.RXModelQueriableImpl$2.call(RXModelQueriableImpl.java:61)
at com.raizlabs.android.dbflow.rx2.language.RXModelQueriableImpl$2.call(RXModelQueriableImpl.java:58)
at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:44)
at io.reactivex.Single.subscribe(Single.java:3575)
at io.reactivex.Single.subscribe(Single.java:3561)
at com.fs.wfm.storage.dbflow.DBFlowWfmStorageRepo$removeOldEventPlanners$1.subscribe(DBFlowWfmStorageRepo.kt:112)
at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
at io.reactivex.Single.subscribe(Single.java:3575)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
有人知道如何解决它吗?
答案 0 :(得分:1)
delete
不会返回值,因此使用queryList()
来返回值作为list是不正确的,并且可以在堆栈跟踪中看到。