@@ -52,9 +52,9 @@ impl MigrationSource<'static> for PathBuf {
52
52
}
53
53
54
54
/// A [`MigrationSource`] implementation with configurable resolution.
55
- ///
55
+ ///
56
56
/// `S` may be `PathBuf`, `&Path` or any type that implements `Into<PathBuf>`.
57
- ///
57
+ ///
58
58
/// See [`ResolveConfig`] for details.
59
59
#[ derive( Debug ) ]
60
60
pub struct ResolveWith < S > ( pub S , pub ResolveConfig ) ;
@@ -97,20 +97,20 @@ impl ResolveConfig {
97
97
}
98
98
99
99
/// Ignore a character when hashing migrations.
100
- ///
100
+ ///
101
101
/// The migration SQL string itself will still contain the character,
102
102
/// but it will not be included when calculating the checksum.
103
- ///
103
+ ///
104
104
/// This can be used to ignore whitespace characters so changing formatting
105
105
/// does not change the checksum.
106
- ///
106
+ ///
107
107
/// Adding the same `char` more than once is a no-op.
108
- ///
108
+ ///
109
109
/// ### Note: Changes Migration Checksum
110
- /// This will change the checksum of resolved migrations,
110
+ /// This will change the checksum of resolved migrations,
111
111
/// which may cause problems with existing deployments.
112
112
///
113
- /// **Use at your own risk.**
113
+ /// **Use at your own risk.**
114
114
pub fn ignore_char ( & mut self , c : char ) -> & mut Self {
115
115
self . ignored_chars . insert ( c) ;
116
116
self
@@ -123,21 +123,21 @@ impl ResolveConfig {
123
123
///
124
124
/// This can be used to ignore whitespace characters so changing formatting
125
125
/// does not change the checksum.
126
- ///
126
+ ///
127
127
/// Adding the same `char` more than once is a no-op.
128
128
///
129
129
/// ### Note: Changes Migration Checksum
130
- /// This will change the checksum of resolved migrations,
130
+ /// This will change the checksum of resolved migrations,
131
131
/// which may cause problems with existing deployments.
132
132
///
133
- /// **Use at your own risk.**
133
+ /// **Use at your own risk.**
134
134
pub fn ignore_chars ( & mut self , chars : impl IntoIterator < Item = char > ) -> & mut Self {
135
135
self . ignored_chars . extend ( chars) ;
136
136
self
137
137
}
138
138
139
139
/// Iterate over the set of ignored characters.
140
- ///
140
+ ///
141
141
/// Duplicate `char`s are not included.
142
142
pub fn ignored_chars ( & self ) -> impl Iterator < Item = char > + ' _ {
143
143
self . ignored_chars . iter ( ) . copied ( )
@@ -266,11 +266,17 @@ fn checksum_with(sql: &str, ignored_chars: &BTreeSet<char>) -> Vec<u8> {
266
266
fn checksum_with_ignored_chars ( ) {
267
267
// Ensure that `checksum_with` returns the same digest for a given set of ignored chars
268
268
// as the equivalent string with the characters removed.
269
- let ignored_chars = [ ' ' , '\t' , '\r' , '\n' ] ;
269
+ let ignored_chars = [
270
+ ' ' , '\t' , '\r' , '\n' ,
271
+ // Zero-width non-breaking space (ZWNBSP), often added as a magic-number at the beginning
272
+ // of UTF-8 encoded files as a byte-order mark (BOM):
273
+ // https://en.wikipedia.org/wiki/Byte_order_mark
274
+ '\u{FEFF}' ,
275
+ ] ;
270
276
271
277
// Copied from `examples/postgres/axum-social-with-tests/migrations/3_comment.sql`
272
278
let sql = "\
273
- create table comment (\r \n \
279
+ \u{FEFF} create table comment (\r \n \
274
280
\t comment_id uuid primary key default gen_random_uuid(),\r \n \
275
281
\t post_id uuid not null references post(post_id),\r \n \
276
282
\t user_id uuid not null references \" user\" (user_id),\r \n \
0 commit comments