Create a predicate for the given ilike pattern
(pattern: &'a str, is_ascii: bool)
| 66 | |
| 67 | /// Create a predicate for the given ilike pattern |
| 68 | pub(crate) fn ilike(pattern: &'a str, is_ascii: bool) -> Result<Self, ArrowError> { |
| 69 | if is_ascii && pattern.is_ascii() { |
| 70 | if !contains_like_pattern(pattern) { |
| 71 | return Ok(Self::IEqAscii(pattern)); |
| 72 | } else if pattern.ends_with('%') |
| 73 | && !pattern.ends_with("\\%") |
| 74 | && !contains_like_pattern(&pattern[..pattern.len() - 1]) |
| 75 | { |
| 76 | return Ok(Self::IStartsWithAscii(&pattern[..pattern.len() - 1])); |
| 77 | } else if pattern.starts_with('%') && !contains_like_pattern(&pattern[1..]) { |
| 78 | return Ok(Self::IEndsWithAscii(&pattern[1..])); |
| 79 | } |
| 80 | } |
| 81 | Ok(Self::Regex(regex_like(pattern, true)?)) |
| 82 | } |
| 83 | |
| 84 | /// Evaluate this predicate against the given haystack |
| 85 | pub(crate) fn evaluate(&self, haystack: &str) -> bool { |
nothing calls this directly
no test coverage detected