Extract the content between the first pair of single quotes after "CRON" in the SQL string.
(sql: &str)
| 9 | /// Extract the content between the first pair of single quotes after |
| 10 | /// "CRON" in the SQL string. |
| 11 | fn extract_quoted_cron(sql: &str) -> Option<String> { |
| 12 | let upper = sql.to_uppercase(); |
| 13 | let cron_idx = upper.find("CRON")?; |
| 14 | let rest = &sql[cron_idx + 4..]; |
| 15 | let start = rest.find('\'')?; |
| 16 | let inner = &rest[start + 1..]; |
| 17 | let mut i = 0; |
| 18 | let bytes = inner.as_bytes(); |
| 19 | while i < bytes.len() { |
| 20 | if bytes[i] == b'\'' { |
| 21 | if i + 1 < bytes.len() && bytes[i + 1] == b'\'' { |
| 22 | i += 2; |
| 23 | continue; |
| 24 | } |
| 25 | return Some(inner[..i].replace("''", "'")); |
| 26 | } |
| 27 | i += 1; |
| 28 | } |
| 29 | None |
| 30 | } |
| 31 | |
| 32 | pub(super) fn try_parse( |
| 33 | upper: &str, |