diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index f865878f4..aca136499 100644 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -2966,7 +2966,10 @@ function ReaderStatistics.onSync(local_path, cached_path, income_path) title, authors, notes, last_open, highlights, pages, series, language, md5, total_read_time, total_read_pages ) SELECT title, authors, notes, last_open, highlights, pages, series, language, md5, total_read_time, total_read_pages - FROM income_db.book WHERE true ON CONFLICT (title, authors, md5) DO NOTHING; + FROM income_db.book + WHERE (title, authors, md5) NOT IN ( + SELECT title, authors, md5 FROM book + ); -- We create a book_id mapping temp table (view not possible due to attached db) CREATE TEMP TABLE book_id_map AS diff --git a/plugins/vocabbuilder.koplugin/db.lua b/plugins/vocabbuilder.koplugin/db.lua index 0a7160996..070117329 100644 --- a/plugins/vocabbuilder.koplugin/db.lua +++ b/plugins/vocabbuilder.koplugin/db.lua @@ -436,7 +436,7 @@ function VocabularyBuilder.onSync(local_path, cached_path, income_path) sql = sql .. [[ -- We merge the local db with income db to form the synced db. -- First we do the books - INSERT OR IGNORE INTO title (name) SELECT name FROM income_db.title; + INSERT INTO title (name) SELECT name FROM income_db.title WHERE name NOT IN (SELECT name FROM title); -- Then update income db's book title id references UPDATE income_db.vocabulary SET title_id = ifnull(