在实际放入数据之前尝试从表中删除时,我得到SQLiteException - no such table
。我正在使用空间。
我的猜测是,只有在插入第一个数据后才能创建表。但是我有一项操作,要求用每个请求替换数据库中的数据:
override fun refreshList(filter: ApplyFilterRequest, page: Int, pageSize: Int, replace: Boolean): Single<FilterResponse> {
var pagedResponseData: ResponseData = ResponseData.list(page, pageSize)
var pagedFilter = filter.copy(responseData = pagedResponseData)
return from(placesApi.applyFilter(pagedFilter))
.doOnSuccess {
var list = it.list?.places
appDatabase.beginTransaction()
list?.let {
var listResult = list.map { ListResult(it.placeId) }
if(replace) {
listResultDao.replace(listResult)//We save each place on the database to be able to reference it by experienceId
}
else{
listResultDao.saveResults(listResult)
}
placesDao.savePlaces(it)
}
appDatabase.setTransactionSuccessful();
appDatabase.endTransaction()
}
.doOnError {
appDatabase.endTransaction()
}
}
以及替换操作:
@Transaction
open fun replace(ids: List<ListResult>) {
deleteAll()
saveResults(ids)
}
@Query("DELETE from list_results")
abstract fun deleteAll()
这将引发以下错误:
Handling Error android.database.sqlite.SQLiteException: no such table: room_table_modification_log (code 1): , while compiling: DELETE from list_results
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(no such table: room_table_modification_log (code 1): , while compiling: DELETE from list_results)
################################################################# with text We couldn't get your places. Please try again.
android.database.sqlite.SQLiteException: no such table: room_table_modification_log (code 1): , while compiling: DELETE from list_results
#################################################################
Error Code : 1 (SQLITE_ERROR)
Caused By : SQL(query) error or missing database.
(no such table: room_table_modification_log (code 1): , while compiling: DELETE from list_results)
如果数据已经到位,那么我不会出错。
答案 0 :(得分:0)
该问题的解决方案是将您的会议室版本更新为高于1.1.0的版本,因为此版本中存在一个已知的错误,您可以使用1.1.1或更高版本。这是错误https://issuetracker.google.com/issues/79362399