From 98de9628343eadaf3b9d23180a9786155b441dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joly?= Date: Tue, 19 Mar 2024 10:04:26 +0000 Subject: [PATCH] misc fixes --- Cargo.toml | 1 - examples/async/src/main.rs | 3 ++- rusqlite_migration/Cargo.toml | 4 ---- rusqlite_migration_tests/Cargo.toml | 3 +-- .../tests/multiline_test.rs | 20 +++++-------------- 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bad2407..e3fbe82 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "rusqlite_migration_tests", "examples/*", ] -exclude = ["examples/target"] # https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2 resolver = "2" diff --git a/examples/async/src/main.rs b/examples/async/src/main.rs index 65c3831..969ddbd 100644 --- a/examples/async/src/main.rs +++ b/examples/async/src/main.rs @@ -55,9 +55,10 @@ async fn main() { // Apply some PRAGMA. These are often better applied outside of migrations, as some needs to be // executed for each connection (like `foreign_keys`) or to be executed outside transactions // (`journal_mode` is a noop in a transaction). -async_conn + async_conn .call(|conn| Ok(conn.pragma_update(None, "journal_mode", "WAL"))) .await + .unwrap() .unwrap(); async_conn .call(|conn| Ok(conn.pragma_update(None, "foreign_keys", "ON"))) diff --git a/rusqlite_migration/Cargo.toml b/rusqlite_migration/Cargo.toml index 5e1e223..5301d52 100644 --- a/rusqlite_migration/Cargo.toml +++ b/rusqlite_migration/Cargo.toml @@ -57,10 +57,6 @@ iai = "0.1" insta = "1.34.0" mutants = "0.0.3" -[dev-dependencies.rusqlite] -version = "*" # The version is constrained by the normal dependency package -features = ["extra_check"] - [[bench]] name = "criterion" harness = false diff --git a/rusqlite_migration_tests/Cargo.toml b/rusqlite_migration_tests/Cargo.toml index fccb459..062d8bd 100644 --- a/rusqlite_migration_tests/Cargo.toml +++ b/rusqlite_migration_tests/Cargo.toml @@ -24,8 +24,7 @@ features = ["alpha-async-tokio-rusqlite", "from-directory"] [dependencies.rusqlite] version = "0.31.0" -default-features = false -features = [] +features = ["extra_check"] [dev-dependencies] tokio-test = "0.4.2" diff --git a/rusqlite_migration_tests/tests/multiline_test.rs b/rusqlite_migration_tests/tests/multiline_test.rs index aad6205..550e59b 100644 --- a/rusqlite_migration_tests/tests/multiline_test.rs +++ b/rusqlite_migration_tests/tests/multiline_test.rs @@ -10,9 +10,8 @@ fn main_test() { let mut ms = vec![M::up( r#" CREATE TABLE friend (name TEXT PRIMARY KEY, email TEXT) WITHOUT ROWID; - PRAGMA journal_mode = WAL; - PRAGMA foreign_keys = ON; ALTER TABLE friend ADD COLUMN birthday TEXT; + ALTER TABLE friend ADD COLUMN notes TEXT; "#, )]; @@ -20,21 +19,12 @@ fn main_test() { let mut conn = Connection::open(&db_file).unwrap(); let migrations = Migrations::new(ms.clone()); - // Will be improved with https://github.com/cljoly/rusqlite_migration/issues/134. For now, - // just make sure the right error is returned - assert!(matches!( - migrations.to_latest(&mut conn), - Err(rusqlite_migration::Error::RusqliteError { - query: _, - err: rusqlite::Error::ExecuteReturnedResults - }) - )); + migrations.to_latest(&mut conn).unwrap(); conn.pragma_update_and_check(None, "journal_mode", "WAL", |r| { - if let Ok(v) = r.get(0) { - Ok(()) - } else { - assert!(false, "unexpected journal_mode after setting it") + match r.get::<_, String>(0) { + Ok(v) if v.to_lowercase() == "wal" => Ok(()), + val => panic!("unexpected journal_mode after setting it: {:?}", val), } }) .unwrap();