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

Function first_sql_word

nodedb-sql/src/parser/preprocess/lex.rs:168–184  ·  view source on GitHub ↗

Return the first SQL keyword/word in `sql`, skipping leading whitespace, line comments, and block comments. Returns `None` if the input is empty or contains only whitespace/comments. The returned slice is a sub-slice of `sql` in its original case.

(sql: &str)

Source from the content-addressed store, hash-verified

166///
167/// The returned slice is a sub-slice of `sql` in its original case.
168pub fn first_sql_word(sql: &str) -> Option<&str> {
169 for seg in segments(sql) {
170 if let SqlSegment::Text(t) = seg {
171 let trimmed = t.trim_start();
172 if trimmed.is_empty() {
173 continue;
174 }
175 let end = trimmed
176 .find(|c: char| c.is_ascii_whitespace() || c == '(' || c == ';')
177 .unwrap_or(trimmed.len());
178 if end > 0 {
179 return Some(&trimmed[..end]);
180 }
181 }
182 }
183 None
184}
185
186/// Return the second SQL keyword/word in `sql`, skipping leading whitespace,
187/// line comments, and block comments, then skipping the first word. Returns

Callers 2

preprocessFunction · 0.85
parseFunction · 0.85

Calls 4

segmentsFunction · 0.85
is_emptyMethod · 0.45
findMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected