mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-27 08:16:36 +03:00
Fix a query
This commit is contained in:
parent
b09345f2e1
commit
92b3f90380
1 changed files with 7 additions and 12 deletions
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||||
import android.util.Pair
|
import android.util.Pair
|
||||||
import com.pushtorefresh.storio.Queries
|
import com.pushtorefresh.storio.Queries
|
||||||
import com.pushtorefresh.storio.sqlite.impl.DefaultStorIOSQLite
|
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.operations.get.PreparedGetObject
|
||||||
import com.pushtorefresh.storio.sqlite.queries.DeleteQuery
|
import com.pushtorefresh.storio.sqlite.queries.DeleteQuery
|
||||||
import com.pushtorefresh.storio.sqlite.queries.Query
|
import com.pushtorefresh.storio.sqlite.queries.Query
|
||||||
|
@ -281,17 +280,13 @@ open class DatabaseHelper(context: Context) {
|
||||||
|
|
||||||
fun insertMangasCategories(mangasCategories: List<MangaCategory>) = db.put().objects(mangasCategories).prepare()
|
fun insertMangasCategories(mangasCategories: List<MangaCategory>) = db.put().objects(mangasCategories).prepare()
|
||||||
|
|
||||||
fun deleteOldMangasCategories(mangas: List<Manga>): PreparedDeleteByQuery {
|
fun deleteOldMangasCategories(mangas: List<Manga>) = db.delete()
|
||||||
val mangaIds = Observable.from(mangas).map { manga -> manga.id }.toList().toBlocking().single()
|
.byQuery(DeleteQuery.builder()
|
||||||
|
.table(MangaCategoryTable.TABLE)
|
||||||
return db.delete()
|
.where("${MangaCategoryTable.COLUMN_MANGA_ID} IN (${Queries.placeholders(mangas.size)})")
|
||||||
.byQuery(DeleteQuery.builder()
|
.whereArgs(*mangas.map { it.id }.toTypedArray())
|
||||||
.table(MangaCategoryTable.TABLE)
|
.build())
|
||||||
.where("${MangaCategoryTable.COLUMN_MANGA_ID} IN (${Queries.placeholders(mangas.size)})")
|
.prepare()
|
||||||
.whereArgs(mangaIds)
|
|
||||||
.build())
|
|
||||||
.prepare()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setMangaCategories(mangasCategories: List<MangaCategory>, mangas: List<Manga>) {
|
fun setMangaCategories(mangasCategories: List<MangaCategory>, mangas: List<Manga>) {
|
||||||
inTransaction {
|
inTransaction {
|
||||||
|
|
Loading…
Reference in a new issue