common_function::utils

Function escape_like_pattern

source
pub fn escape_like_pattern(pattern: &str) -> String
Expand description

Escapes special characters in the provided pattern string for LIKE.

Specifically, it prefixes the backslash (\), percent (%), and underscore (_) characters with an additional backslash to ensure they are treated literally.

ยงExamples

let escaped = escape_pattern("100%_some\\path");
assert_eq!(escaped, "100\\%\\_some\\\\path");