mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-04 08:15:39 +00:00
chore: test ignored_chars with U+FEFF
(ZWNBSP/BOM)
https://en.wikipedia.org/wiki/Byte_order_mark
This commit is contained in:
parent
062a06fc78
commit
9f34fc8dd2
@ -155,7 +155,11 @@ migrations_dir = "foo/migrations"
|
|||||||
# ignored_chars = ["\r"]
|
# ignored_chars = ["\r"]
|
||||||
|
|
||||||
# Ignore common whitespace characters (beware syntatically significant whitespace!)
|
# Ignore common whitespace characters (beware syntatically significant whitespace!)
|
||||||
ignored_chars = [" ", "\t", "\r", "\n"] # Space, tab, CR, LF
|
# Space, tab, CR, LF, zero-width non-breaking space (U+FEFF)
|
||||||
|
#
|
||||||
|
# U+FEFF is added by some editors as a magic number at the beginning of a text file indicating it is UTF-8 encoded,
|
||||||
|
# where it is known as a byte-order mark (BOM): https://en.wikipedia.org/wiki/Byte_order_mark
|
||||||
|
ignored_chars = [" ", "\t", "\r", "\n", "\uFEFF"]
|
||||||
|
|
||||||
# Specify reversible migrations by default (for `sqlx migrate create`).
|
# Specify reversible migrations by default (for `sqlx migrate create`).
|
||||||
#
|
#
|
||||||
|
@ -81,7 +81,7 @@ fn assert_migrate_config(config: &config::migrate::Config) {
|
|||||||
assert_eq!(config.table_name.as_deref(), Some("foo._sqlx_migrations"));
|
assert_eq!(config.table_name.as_deref(), Some("foo._sqlx_migrations"));
|
||||||
assert_eq!(config.migrations_dir.as_deref(), Some("foo/migrations"));
|
assert_eq!(config.migrations_dir.as_deref(), Some("foo/migrations"));
|
||||||
|
|
||||||
let ignored_chars = BTreeSet::from([' ', '\t', '\r', '\n']);
|
let ignored_chars = BTreeSet::from([' ', '\t', '\r', '\n', '\u{FEFF}']);
|
||||||
|
|
||||||
assert_eq!(config.ignored_chars, ignored_chars);
|
assert_eq!(config.ignored_chars, ignored_chars);
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ pub fn checksum_fragments<'a>(fragments: impl Iterator<Item = &'a str>) -> Vec<u
|
|||||||
fn fragments_checksum_equals_full_checksum() {
|
fn fragments_checksum_equals_full_checksum() {
|
||||||
// Copied from `examples/postgres/axum-social-with-tests/migrations/3_comment.sql`
|
// Copied from `examples/postgres/axum-social-with-tests/migrations/3_comment.sql`
|
||||||
let sql = "\
|
let sql = "\
|
||||||
create table comment (\r\n\
|
\u{FEFF}create table comment (\r\n\
|
||||||
\tcomment_id uuid primary key default gen_random_uuid(),\r\n\
|
\tcomment_id uuid primary key default gen_random_uuid(),\r\n\
|
||||||
\tpost_id uuid not null references post(post_id),\r\n\
|
\tpost_id uuid not null references post(post_id),\r\n\
|
||||||
\tuser_id uuid not null references \"user\"(user_id),\r\n\
|
\tuser_id uuid not null references \"user\"(user_id),\r\n\
|
||||||
|
@ -266,11 +266,17 @@ fn checksum_with(sql: &str, ignored_chars: &BTreeSet<char>) -> Vec<u8> {
|
|||||||
fn checksum_with_ignored_chars() {
|
fn checksum_with_ignored_chars() {
|
||||||
// Ensure that `checksum_with` returns the same digest for a given set of ignored chars
|
// Ensure that `checksum_with` returns the same digest for a given set of ignored chars
|
||||||
// as the equivalent string with the characters removed.
|
// as the equivalent string with the characters removed.
|
||||||
let ignored_chars = [' ', '\t', '\r', '\n'];
|
let ignored_chars = [
|
||||||
|
' ', '\t', '\r', '\n',
|
||||||
|
// Zero-width non-breaking space (ZWNBSP), often added as a magic-number at the beginning
|
||||||
|
// of UTF-8 encoded files as a byte-order mark (BOM):
|
||||||
|
// https://en.wikipedia.org/wiki/Byte_order_mark
|
||||||
|
'\u{FEFF}',
|
||||||
|
];
|
||||||
|
|
||||||
// Copied from `examples/postgres/axum-social-with-tests/migrations/3_comment.sql`
|
// Copied from `examples/postgres/axum-social-with-tests/migrations/3_comment.sql`
|
||||||
let sql = "\
|
let sql = "\
|
||||||
create table comment (\r\n\
|
\u{FEFF}create table comment (\r\n\
|
||||||
\tcomment_id uuid primary key default gen_random_uuid(),\r\n\
|
\tcomment_id uuid primary key default gen_random_uuid(),\r\n\
|
||||||
\tpost_id uuid not null references post(post_id),\r\n\
|
\tpost_id uuid not null references post(post_id),\r\n\
|
||||||
\tuser_id uuid not null references \"user\"(user_id),\r\n\
|
\tuser_id uuid not null references \"user\"(user_id),\r\n\
|
||||||
|
Loading…
x
Reference in New Issue
Block a user