Create a predicate for the given like pattern
(pattern: &'a str)
| 44 | impl<'a> Predicate<'a> { |
| 45 | /// Create a predicate for the given like pattern |
| 46 | pub(crate) fn like(pattern: &'a str) -> Result<Self, ArrowError> { |
| 47 | if !contains_like_pattern(pattern) { |
| 48 | Ok(Self::Eq(pattern)) |
| 49 | } else if pattern.ends_with('%') && !contains_like_pattern(&pattern[..pattern.len() - 1]) { |
| 50 | Ok(Self::StartsWith(&pattern[..pattern.len() - 1])) |
| 51 | } else if pattern.starts_with('%') && !contains_like_pattern(&pattern[1..]) { |
| 52 | Ok(Self::EndsWith(&pattern[1..])) |
| 53 | } else if pattern.starts_with('%') |
| 54 | && pattern.ends_with('%') |
| 55 | && !contains_like_pattern(&pattern[1..pattern.len() - 1]) |
| 56 | { |
| 57 | Ok(Self::contains(&pattern[1..pattern.len() - 1])) |
| 58 | } else { |
| 59 | Ok(Self::Regex(regex_like(pattern, false)?)) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | pub(crate) fn contains(needle: &'a str) -> Self { |
| 64 | Self::Contains(Finder::new(needle.as_bytes())) |
nothing calls this directly
no test coverage detected