Skip to content

Commit

Permalink
rewrite escape_pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
  • Loading branch information
waynexia committed Jul 1, 2024
1 parent fa3f5de commit b9572ba
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/common/function/src/scalars/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,12 @@ impl PatternAst {

fn escape_pattern(pattern: &str) -> String {
pattern
.replace('\\', "\\\\")
.replace('%', "\\%")
.replace('_', "\\_")
.chars()
.flat_map(|c| match c {
'\\' | '%' | '_' => vec!['\\', c],
_ => vec![c],
})
.collect::<String>()
}
}

Expand Down

0 comments on commit b9572ba

Please sign in to comment.