Fix chapters and categories not being added to database
Closes #3278 Fixes #3291
This commit is contained in:
-1
@@ -28,7 +28,6 @@ class CategoriesRestorer(
|
||||
val order = nextOrder++
|
||||
database.categoriesQueries
|
||||
.insert(it.name, order, it.flags)
|
||||
.awaitAsOne()
|
||||
.let { id -> it.toCategory(id).copy(order = order) }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -241,7 +241,7 @@ class MangaRestorer(
|
||||
* @return id of [Manga], null if not found
|
||||
*/
|
||||
private suspend fun insertManga(manga: Manga): Long {
|
||||
return database.mangasQueries.insert(
|
||||
return database.mangasQueries.insertReturningId(
|
||||
source = manga.source,
|
||||
url = manga.url,
|
||||
artist = manga.artist,
|
||||
|
||||
@@ -21,7 +21,7 @@ class ChapterRepositoryImpl(
|
||||
return try {
|
||||
database.transactionWithResult {
|
||||
chapters.map { chapter ->
|
||||
val lastInsertId = database.chaptersQueries.insert(
|
||||
val chapterId = database.chaptersQueries.insertReturningId(
|
||||
chapter.mangaId,
|
||||
chapter.url,
|
||||
chapter.name,
|
||||
@@ -34,8 +34,9 @@ class ChapterRepositoryImpl(
|
||||
chapter.dateFetch,
|
||||
chapter.dateUpload,
|
||||
chapter.version,
|
||||
).awaitAsOne()
|
||||
chapter.copy(id = lastInsertId)
|
||||
)
|
||||
.awaitAsOne()
|
||||
chapter.copy(id = chapterId)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -42,12 +42,9 @@ JOIN mangas_categories MC
|
||||
ON C._id = MC.category_id
|
||||
WHERE MC.manga_id = :mangaId;
|
||||
|
||||
insert {
|
||||
INSERT INTO categories(name, sort, flags)
|
||||
VALUES (:name, :order, :flags);
|
||||
|
||||
SELECT last_insert_rowid();
|
||||
}
|
||||
insert:
|
||||
INSERT INTO categories(name, sort, flags)
|
||||
VALUES (:name, :order, :flags);
|
||||
|
||||
delete:
|
||||
DELETE FROM categories
|
||||
|
||||
@@ -97,12 +97,15 @@ UPDATE chapters
|
||||
SET is_syncing = 0
|
||||
WHERE is_syncing = 1;
|
||||
|
||||
insert {
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, last_modified_at, version, is_syncing)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, 0, :version, 0);
|
||||
insert:
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, last_modified_at, version, is_syncing)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, 0, :version, 0);
|
||||
|
||||
insertReturningId:
|
||||
INSERT INTO chapters(manga_id, url, name, scanlator, read, bookmark, last_page_read, chapter_number, source_order, date_fetch, date_upload, last_modified_at, version, is_syncing)
|
||||
VALUES (:mangaId, :url, :name, :scanlator, :read, :bookmark, :lastPageRead, :chapterNumber, :sourceOrder, :dateFetch, :dateUpload, 0, :version, 0)
|
||||
RETURNING _id;
|
||||
|
||||
SELECT last_insert_rowid();
|
||||
}
|
||||
update:
|
||||
UPDATE chapters
|
||||
SET manga_id = coalesce(:mangaId, manga_id),
|
||||
|
||||
@@ -193,12 +193,10 @@ AND (
|
||||
)
|
||||
);
|
||||
|
||||
insert {
|
||||
INSERT INTO mangas(source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update, next_update, initialized, viewer, chapter_flags, cover_last_modified, date_added, update_strategy, calculate_interval, last_modified_at, version, notes)
|
||||
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :chapterFlags, :coverLastModified, :dateAdded, :updateStrategy, :calculateInterval, 0, :version, :notes);
|
||||
|
||||
SELECT last_insert_rowid();
|
||||
}
|
||||
insertReturningId:
|
||||
INSERT INTO mangas(source, url, artist, author, description, genre, title, status, thumbnail_url, favorite, last_update, next_update, initialized, viewer, chapter_flags, cover_last_modified, date_added, update_strategy, calculate_interval, last_modified_at, version, notes)
|
||||
VALUES (:source, :url, :artist, :author, :description, :genre, :title, :status, :thumbnailUrl, :favorite, :lastUpdate, :nextUpdate, :initialized, :viewerFlags, :chapterFlags, :coverLastModified, :dateAdded, :updateStrategy, :calculateInterval, 0, :version, :notes)
|
||||
RETURNING _id;
|
||||
|
||||
update:
|
||||
UPDATE mangas SET
|
||||
|
||||
Reference in New Issue
Block a user