Parse a list of SQL strings and downcast each to a specific statement type. Each string is parsed via [`parse_one_statement`], then passed through `parser` to extract the expected AST variant (e.g., `CreateIndexStatement`). Returns `Err(())` if any string fails to parse or has the wrong statement type.
(
sql_statements: &[String],
parser: fn(Statement<Raw>) -> Result<T, ()>,
)
| 1091 | /// `parser` to extract the expected AST variant (e.g., `CreateIndexStatement`). |
| 1092 | /// Returns `Err(())` if any string fails to parse or has the wrong statement type. |
| 1093 | fn parse_statement_list<T>( |
| 1094 | sql_statements: &[String], |
| 1095 | parser: fn(Statement<Raw>) -> Result<T, ()>, |
| 1096 | ) -> Result<Vec<T>, ()> { |
| 1097 | sql_statements |
| 1098 | .iter() |
| 1099 | .map(|sql| parse_one_statement(sql).and_then(parser)) |
| 1100 | .collect() |
| 1101 | } |
| 1102 | |
| 1103 | /// Parse a cached main statement SQL string into the project's [`Statement`](crate::project::ast::Statement) enum. |
| 1104 | /// |
no test coverage detected