From 995bc5e3edc22602b382cdd94e7679023d9eeee5 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Wed, 26 May 2021 13:29:43 +0200 Subject: [PATCH] updated to rusqlite 0.25 --- Cargo.lock | 50 ++++++++++++++++++++++++++++++++++++++----------- Cargo.toml | 2 +- src/database.rs | 32 +++++++++++++++---------------- 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e8022d4..ced2d54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,9 +8,14 @@ checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" [[package]] name = "ahash" -version = "0.4.7" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" +checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] [[package]] name = "bitflags" @@ -97,19 +102,30 @@ dependencies = [ ] [[package]] -name = "hashbrown" -version = "0.9.1" +name = "getrandom" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" +checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ "ahash", ] [[package]] name = "hashlink" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d99cf782f0dc4372d26846bec3de7804ceb5df083c2d4462c0b8d2330e894fa8" +checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" dependencies = [ "hashbrown", ] @@ -122,9 +138,9 @@ checksum = "265d751d31d6780a3f956bb5b8022feba2d94eeee5a84ba64f4212eedca42213" [[package]] name = "libsqlite3-sys" -version = "0.20.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d31059f22935e6c31830db5249ba2b7ecd54fd73a9909286f0a67aa55c2fbd" +checksum = "290b64917f8b0cb885d9de0f9959fe1f775d7fa12f1da2db9001c1c8ab60f89d" dependencies = [ "cc", "pkg-config", @@ -146,6 +162,12 @@ dependencies = [ "adler32", ] +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + [[package]] name = "pbdbfixer" version = "0.8.0" @@ -190,9 +212,9 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.24.2" +version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38ee71cbab2c827ec0ac24e76f82eca723cee92c509a65f67dee393c25112" +checksum = "57adcf67c8faaf96f3248c2a7b419a0dbc52ebe36ba83dd57fe83827c1ea4eb3" dependencies = [ "bitflags", "fallible-iterator", @@ -263,6 +285,12 @@ version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + [[package]] name = "wasi" version = "0.10.0+wasi-snapshot-preview1" diff --git a/Cargo.toml b/Cargo.toml index 57db8d2..f6143dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,5 +11,5 @@ zip = "0.5" quick-xml = "0.22" [dependencies.rusqlite] -version = "0.24" +version = "0.25" features = ["bundled"] diff --git a/src/database.rs b/src/database.rs index 1ce6aea..a4149ea 100644 --- a/src/database.rs +++ b/src/database.rs @@ -1,4 +1,4 @@ -use rusqlite::{named_params, Connection, Transaction, NO_PARAMS}; +use rusqlite::{named_params, Connection, Transaction}; use crate::epub; @@ -35,7 +35,7 @@ fn get_epubs_from_database(tx: &Transaction) -> Vec { ) .unwrap(); - let mut rows = stmt.query(NO_PARAMS).unwrap(); + let mut rows = stmt.query([]).unwrap(); while let Some(row) = rows.next().unwrap() { let book_id: i32 = row.get(0).unwrap(); @@ -79,44 +79,44 @@ fn remove_ghost_books_from_db(tx: &Transaction) -> usize { ) .unwrap(); - let num = stmt.execute(NO_PARAMS).unwrap(); + let num = stmt.execute([]).unwrap(); tx.execute( r#"DELETE FROM books_settings WHERE bookid NOT IN ( SELECT id FROM books_impl )"#, - NO_PARAMS, + [], ) .unwrap(); let version: i32 = tx - .query_row(r#"SELECT id FROM version"#, NO_PARAMS, |r| r.get(0)) + .query_row(r#"SELECT id FROM version"#, [], |r| r.get(0)) .unwrap(); if version >= 37 { tx.execute( r#"DELETE FROM books_fast_hashes WHERE book_id NOT IN ( SELECT id FROM books_impl )"#, - NO_PARAMS, + [], ) .unwrap(); } else { tx.execute( r#"DELETE FROM books_uids WHERE book_id NOT IN ( SELECT id FROM books_impl )"#, - NO_PARAMS, + [], ) .unwrap(); } tx.execute( r#"DELETE FROM bookshelfs_books WHERE bookid NOT IN ( SELECT id FROM books_impl )"#, - NO_PARAMS, + [], ) .unwrap(); tx.execute( r#"DELETE FROM booktogenre WHERE bookid NOT IN ( SELECT id FROM books_impl )"#, - NO_PARAMS, + [], ) .unwrap(); tx.execute( r#"DELETE FROM social WHERE bookid NOT IN ( SELECT id FROM books_impl )"#, - NO_PARAMS, + [], ) .unwrap(); @@ -170,7 +170,7 @@ pub fn fix_db_entries() -> Statistics { let mut stmt = tx .prepare("UPDATE books_impl SET firstauthor = :file_as WHERE id = :book_id") .unwrap(); - stmt.execute_named( + stmt.execute( named_params![":file_as": firstauthors.join(" & "), ":book_id": entry.id], ) .unwrap(); @@ -190,7 +190,7 @@ pub fn fix_db_entries() -> Statistics { let mut stmt = tx .prepare("UPDATE books_impl SET first_author_letter = :first_letter WHERE id = :book_id") .unwrap(); - stmt.execute_named( + stmt.execute( named_params![":first_letter": first_author_letter,":book_id": entry.id], ) .unwrap(); @@ -209,7 +209,7 @@ pub fn fix_db_entries() -> Statistics { let mut stmt = tx .prepare("UPDATE books_impl SET author = :authors WHERE id = :book_id") .unwrap(); - stmt.execute_named( + stmt.execute( named_params![":authors": authornames.join(", "), ":book_id": entry.id], ) .unwrap(); @@ -221,7 +221,7 @@ pub fn fix_db_entries() -> Statistics { let mut stmt = tx .prepare(r#"INSERT INTO genres (name) SELECT :genre ON CONFLICT DO NOTHING"#) .unwrap(); - stmt.execute_named(named_params![":genre": &epub_metadata.genre]) + stmt.execute(named_params![":genre": &epub_metadata.genre]) .unwrap(); let mut stmt = tx .prepare( @@ -233,7 +233,7 @@ pub fn fix_db_entries() -> Statistics { ON CONFLICT DO NOTHING"#, ) .unwrap(); - stmt.execute_named( + stmt.execute( named_params![":bookid": &entry.id, ":genre": &epub_metadata.genre], ) .unwrap(); @@ -245,7 +245,7 @@ pub fn fix_db_entries() -> Statistics { let mut stmt = tx .prepare("UPDATE books_impl SET series = :series, numinseries = :series_index WHERE id = :book_id") .unwrap(); - stmt.execute_named( + stmt.execute( named_params![":series": &epub_metadata.series.name, ":series_index": &epub_metadata.series.index, ":book_id": entry.id], ) .unwrap();