Skip to content

Commit

Permalink
feat: make sql code hash independent from CR/LF line endings and trai…
Browse files Browse the repository at this point in the history
…ling/leading spaces.
  • Loading branch information
dmk978 committed Jul 16, 2024
1 parent 394f0f8 commit 617592e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions refinery/tests/rusqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ mod rusqlite {
assert_eq!("initial", migrations[0].name());
assert_eq!("add_cars_table", applied_migrations[1].name());

assert_eq!(2959965718684201605, applied_migrations[0].checksum());
assert_eq!(8238603820526370208, applied_migrations[1].checksum());
assert_eq!(1002061374193754426, applied_migrations[0].checksum());
assert_eq!(17421455799783963888, applied_migrations[1].checksum());
}
#[test]

Expand Down Expand Up @@ -385,8 +385,8 @@ mod rusqlite {
assert_eq!("initial", migrations[0].name());
assert_eq!("add_cars_table", applied_migrations[1].name());

assert_eq!(2959965718684201605, applied_migrations[0].checksum());
assert_eq!(8238603820526370208, applied_migrations[1].checksum());
assert_eq!(1002061374193754426, applied_migrations[0].checksum());
assert_eq!(17421455799783963888, applied_migrations[1].checksum());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion refinery_core/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl Migration {
let mut hasher = SipHasher13::new();
name.hash(&mut hasher);
version.hash(&mut hasher);
sql.hash(&mut hasher);
sql.lines().for_each(|line| line.trim().hash(&mut hasher));
let checksum = hasher.finish();

Ok(Migration {
Expand Down

0 comments on commit 617592e

Please sign in to comment.