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

Function extract_using_from_upper

nodedb-sql/src/ddl_ast/parse/rls.rs:154–179  ·  view source on GitHub ↗

Fallback: extract predicate text from the uppercased SQL string when USING appears without space-separated parts matching (e.g. `USING(x=1)`).

(upper: &str)

Source from the content-addressed store, hash-verified

152/// Fallback: extract predicate text from the uppercased SQL string when
153/// USING appears without space-separated parts matching (e.g. `USING(x=1)`).
154fn extract_using_from_upper(upper: &str) -> String {
155 let Some(start) = upper.find("USING") else {
156 return String::new();
157 };
158 let after = &upper[start + 5..].trim_start();
159 if after.starts_with('(') {
160 let mut depth = 0usize;
161 let mut end = 0;
162 for (i, ch) in after.char_indices() {
163 match ch {
164 '(' => depth += 1,
165 ')' => {
166 depth -= 1;
167 if depth == 0 {
168 end = i;
169 break;
170 }
171 }
172 _ => {}
173 }
174 }
175 after[1..end].trim().to_string()
176 } else {
177 String::new()
178 }
179}

Callers 1

parse_create_rls_policyFunction · 0.85

Calls 2

to_stringMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected