| 382 | } |
| 383 | |
| 384 | fn parse_explain_sql(line_reader: &mut LineReader) -> Result<SqlCommand, PosError> { |
| 385 | let (_, line1) = line_reader.next().unwrap(); |
| 386 | let expected_start = line_reader.consumed_raw_pos; |
| 387 | // This is a bit of a hack to extract the next chunk of the file with |
| 388 | // blank lines intact. Ideally the `LineReader` would expose the API we |
| 389 | // need directly, but that would require a large refactor. |
| 390 | let mut expected_output: String = line_reader |
| 391 | .inner |
| 392 | .lines() |
| 393 | .filter(|l| !matches!(l.chars().next(), Some('#'))) |
| 394 | .take_while(|l| !is_sigil(l.chars().next())) |
| 395 | .fold(String::new(), |mut output, l| { |
| 396 | let _ = write!(output, "{}\n", l); |
| 397 | output |
| 398 | }); |
| 399 | while expected_output.ends_with("\n\n") { |
| 400 | expected_output.pop(); |
| 401 | } |
| 402 | // We parsed the multiline expected_output directly using line_reader.inner |
| 403 | // above. |
| 404 | slurp_all(line_reader); |
| 405 | let expected_end = line_reader.consumed_raw_pos; |
| 406 | |
| 407 | Ok(SqlCommand { |
| 408 | query: line1[1..].trim().to_owned(), |
| 409 | expected_output: SqlOutput::Full { |
| 410 | column_names: None, |
| 411 | expected_rows: vec![vec![expected_output]], |
| 412 | }, |
| 413 | expected_start, |
| 414 | expected_end, |
| 415 | }) |
| 416 | } |
| 417 | |
| 418 | fn parse_fail_sql(line_reader: &mut LineReader) -> Result<FailSqlCommand, PosError> { |
| 419 | let (pos, line1) = line_reader.next().unwrap(); |