From 617592eb5425b313a94aa502933ad40c7a8df0c6 Mon Sep 17 00:00:00 2001 From: "Dmitry E. Karasev" Date: Tue, 16 Jul 2024 22:08:48 +0300 Subject: [PATCH] feat: make sql code hash independent from CR/LF line endings and trailing/leading spaces. --- refinery/tests/rusqlite.rs | 8 ++++---- refinery_core/src/runner.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/refinery/tests/rusqlite.rs b/refinery/tests/rusqlite.rs index 258af424..2223c75e 100644 --- a/refinery/tests/rusqlite.rs +++ b/refinery/tests/rusqlite.rs @@ -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] @@ -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] diff --git a/refinery_core/src/runner.rs b/refinery_core/src/runner.rs index 46d4d714..daba0396 100644 --- a/refinery_core/src/runner.rs +++ b/refinery_core/src/runner.rs @@ -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 {