Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cljoly committed Mar 19, 2024
1 parent bda1e4f commit 98de962
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion examples/async/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")))
Expand Down
4 changes: 0 additions & 4 deletions rusqlite_migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions rusqlite_migration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 5 additions & 15 deletions rusqlite_migration_tests/tests/multiline_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,21 @@ 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;
"#,
)];

{
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();
Expand Down

0 comments on commit 98de962

Please sign in to comment.