Return the second SQL keyword/word in `sql`, skipping leading whitespace, line comments, and block comments, then skipping the first word. Returns `None` if there is no second word. The returned slice is a sub-slice of `sql` in its original case.
(sql: &str)
| 189 | /// |
| 190 | /// The returned slice is a sub-slice of `sql` in its original case. |
| 191 | pub fn second_sql_word(sql: &str) -> Option<&str> { |
| 192 | let mut found_first = false; |
| 193 | for seg in segments(sql) { |
| 194 | if let SqlSegment::Text(t) = seg { |
| 195 | let mut remaining = t; |
| 196 | loop { |
| 197 | let trimmed = remaining.trim_start(); |
| 198 | if trimmed.is_empty() { |
| 199 | break; |
| 200 | } |
| 201 | let end = trimmed |
| 202 | .find(|c: char| c.is_ascii_whitespace() || c == '(' || c == ';') |
| 203 | .unwrap_or(trimmed.len()); |
| 204 | if end == 0 { |
| 205 | break; |
| 206 | } |
| 207 | if !found_first { |
| 208 | found_first = true; |
| 209 | // advance past this word |
| 210 | remaining = &trimmed[end..]; |
| 211 | } else { |
| 212 | return Some(&trimmed[..end]); |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | None |
| 218 | } |
| 219 | |
| 220 | /// Return `true` if `op` appears verbatim inside any `Text` segment of `sql`. |
| 221 | /// The comparison is byte-exact (case-sensitive). Occurrences inside string |