Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc. test fixes #25

Merged
merged 2 commits into from
Nov 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ impl<'m> Migrations<'m> {
/// migrations.to_latest(&mut conn).unwrap();
///
/// // You can then insert values in the database
/// conn.execute("INSERT INTO animals (name) VALUES ('dog')", []).unwrap();
/// conn.execute("INSERT INTO food (name) VALUES ('carrot')", []).unwrap();
/// conn.execute("INSERT INTO animals (name) VALUES (?)", ["dog"]).unwrap();
/// conn.execute("INSERT INTO food (name) VALUES (?)", ["carrot"]).unwrap();
/// ```
pub fn to_latest(&self, conn: &mut Connection) -> Result<()> {
let v_max = self.max_schema_version();
Expand Down Expand Up @@ -481,13 +481,13 @@ impl<'m> Migrations<'m> {
///
/// // Go back to version 1, i.e. after running the first migration
/// migrations.to_version(&mut conn, 1);
/// conn.execute("INSERT INTO animals (name) VALUES ('dog')", []).unwrap();
/// conn.execute("INSERT INTO food (name) VALUES ('carrot')", []).unwrap_err();
/// conn.execute("INSERT INTO animals (name) VALUES (?)", ["dog"]).unwrap();
/// conn.execute("INSERT INTO food (name) VALUES (?)", ["carrot"]).unwrap_err();
///
/// // Go back to an empty database
/// migrations.to_version(&mut conn, 0);
/// conn.execute("INSERT INTO animals (name) VALUES ('cat')", []).unwrap_err();
/// conn.execute("INSERT INTO food (name) VALUES ('milk')", []).unwrap_err();
/// conn.execute("INSERT INTO animals (name) VALUES (?)", ["cat"]).unwrap_err();
/// conn.execute("INSERT INTO food (name) VALUES (?)", ["milk"]).unwrap_err();
/// ```
///
/// # Errors
Expand Down Expand Up @@ -557,6 +557,8 @@ fn user_version(conn: &Connection) -> Result<usize, rusqlite::Error> {
fn set_user_version(conn: &Connection, v: usize) -> Result<()> {
trace!("set user version to: {}", v);
let v = v as u32;
// To keep compatibility with lower rusqlite versions, allow the needless `&v` borrow
#[allow(clippy::needless_borrow)]
conn.pragma_update(None, "user_version", &v)
.map_err(|e| Error::RusqliteError {
query: format!("PRAGMA user_version = {}; -- Approximate query", v),
Expand Down