MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_quoted_cron

Function extract_quoted_cron

nodedb-sql/src/ddl_ast/parse/schedule.rs:11–30  ·  view source on GitHub ↗

Extract the content between the first pair of single quotes after "CRON" in the SQL string.

(sql: &str)

Source from the content-addressed store, hash-verified

9/// Extract the content between the first pair of single quotes after
10/// "CRON" in the SQL string.
11fn 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
32pub(super) fn try_parse(
33 upper: &str,

Callers 1

try_parseFunction · 0.85

Calls 4

replaceMethod · 0.80
findMethod · 0.45
as_bytesMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected