Skip to content

Commit d107bed

Browse files
committed
Fix regex to allow multiple whitespaces
1 parent 1fcf31b commit d107bed

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- +refinery NO TRANSACTION
1+
-- +refinery NO TRANSACTION
22
BEGIN;
33
INSERT INTO cars(id, name, brand) VALUES (2, "muscle", "toyota");
44
COMMIT;

refinery_core/src/util.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ fn file_re_all() -> &'static Regex {
3232
/// of a transaction.
3333
fn query_no_transaction_re_sql() -> &'static Regex {
3434
static RE: OnceLock<Regex> = OnceLock::new();
35-
RE.get_or_init(|| Regex::new(r"^[-]{2,}[\s]?(\+refinery NO TRANSACTION)$").unwrap())
35+
RE.get_or_init(|| {
36+
Regex::new(r"^[-]{2,}[\s]?(\+refinery[\s]+NO[\s]+TRANSACTION[\s]?)$").unwrap()
37+
})
3638
}
3739

3840
/// Matches the annotation `// +refinery NO TRANSACTION` at the start of a
3941
/// commented line of a .rs|.sql file, implying that the query should ran outside
4042
/// of a transaction.
4143
fn query_no_transaction_re_all() -> &'static Regex {
4244
static RE: OnceLock<Regex> = OnceLock::new();
43-
RE.get_or_init(|| Regex::new(r"^[-|\/]{2,}[\s]?(\+refinery NO TRANSACTION)$").unwrap())
45+
RE.get_or_init(|| {
46+
Regex::new(r"^[-|\/]{2,}[\s]?(\+refinery[\s]+NO[\s]+TRANSACTION[\s]?)$").unwrap()
47+
})
4448
}
4549

4650
/// enum containing the migration types used to search for migrations

0 commit comments

Comments
 (0)