Extract table name from INSERT statement
(query: &str)
| 2711 | |
| 2712 | /// Extract table name from INSERT statement |
| 2713 | fn extract_table_name_from_insert(query: &str) -> Option<String> { |
| 2714 | // Look for INSERT INTO pattern with case-insensitive search |
| 2715 | let insert_pos = query.as_bytes().windows(11) |
| 2716 | .position(|window| window.eq_ignore_ascii_case(b"INSERT INTO"))?; |
| 2717 | |
| 2718 | let after_insert = &query[insert_pos + 11..].trim(); |
| 2719 | |
| 2720 | // Find the end of table name |
| 2721 | let table_end = after_insert.find(|c: char| { |
| 2722 | c.is_whitespace() || c == '(' || c == ';' |
| 2723 | }).unwrap_or(after_insert.len()); |
| 2724 | |
| 2725 | let table_name = after_insert[..table_end].trim(); |
| 2726 | |
| 2727 | // Remove quotes if present |
| 2728 | let table_name = table_name.trim_matches('"').trim_matches('\''); |
| 2729 | |
| 2730 | if !table_name.is_empty() { |
| 2731 | Some(table_name.to_string()) |
| 2732 | } else { |
| 2733 | None |
| 2734 | } |
| 2735 | } |
| 2736 | |
| 2737 | /// Extract table name from UPDATE statement |
| 2738 | fn extract_table_name_from_update(query: &str) -> Option<String> { |
no test coverage detected