Extract the left operand before `<->`: a column name or dotted path.
(before: &str)
| 16 | |
| 17 | /// Extract the left operand before `<->`: a column name or dotted path. |
| 18 | fn extract_left_operand(before: &str) -> Option<String> { |
| 19 | // Determine what the effective "before" text is by looking only at the |
| 20 | // last Text segment — the operand cannot span across a quoted literal. |
| 21 | let text_before = last_text_segment(before); |
| 22 | let trimmed = text_before.trim_end(); |
| 23 | let start = trimmed |
| 24 | .rfind(|c: char| !c.is_ascii_alphanumeric() && c != '_' && c != '.') |
| 25 | .map(|p| p + 1) |
| 26 | .unwrap_or(0); |
| 27 | let ident = &trimmed[start..]; |
| 28 | if ident.is_empty() { |
| 29 | return None; |
| 30 | } |
| 31 | // Reconstruct including the prefix text up to the ident within `before`. |
| 32 | // We need the ident string only (the caller uses its length for offset math |
| 33 | // and only the text content for the rewrite). |
| 34 | Some(ident.to_string()) |
| 35 | } |
| 36 | |
| 37 | /// Return the content of the last `Text` segment in `sql`, or the whole |
| 38 | /// string if there are no non-text segments. |
no test coverage detected