From 92b3f90380498eca8d6fdab95a70e413cddb9031 Mon Sep 17 00:00:00 2001 From: len Date: Sat, 19 Mar 2016 22:38:40 +0100 Subject: [PATCH] Fix a query --- .../tachiyomi/data/database/DatabaseHelper.kt | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt index 67e988303b..6c2ad4a298 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/DatabaseHelper.kt @@ -4,7 +4,6 @@ import android.content.Context import android.util.Pair import com.pushtorefresh.storio.Queries import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite -import com.pushtorefresh.storio.sqlite.operations.delete.PreparedDeleteByQuery import com.pushtorefresh.storio.sqlite.operations.get.PreparedGetObject import com.pushtorefresh.storio.sqlite.queries.DeleteQuery import com.pushtorefresh.storio.sqlite.queries.Query @@ -281,17 +280,13 @@ open class DatabaseHelper(context: Context) { fun insertMangasCategories(mangasCategories: List) = db.put().objects(mangasCategories).prepare() - fun deleteOldMangasCategories(mangas: List): PreparedDeleteByQuery { - val mangaIds = Observable.from(mangas).map { manga -> manga.id }.toList().toBlocking().single() - - return db.delete() - .byQuery(DeleteQuery.builder() - .table(MangaCategoryTable.TABLE) - .where("${MangaCategoryTable.COLUMN_MANGA_ID} IN (${Queries.placeholders(mangas.size)})") - .whereArgs(mangaIds) - .build()) - .prepare() - } + fun deleteOldMangasCategories(mangas: List) = db.delete() + .byQuery(DeleteQuery.builder() + .table(MangaCategoryTable.TABLE) + .where("${MangaCategoryTable.COLUMN_MANGA_ID} IN (${Queries.placeholders(mangas.size)})") + .whereArgs(*mangas.map { it.id }.toTypedArray()) + .build()) + .prepare() fun setMangaCategories(mangasCategories: List, mangas: List) { inTransaction {