Skip to content

Commit

Permalink
Refactor ResposeStream to require explict call to complete (#1377)
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazerzen authored Oct 9, 2024
1 parent 4601dc6 commit 7e8dd93
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,7 @@ where
if let Some(el) = self.next_element().await {
Some(Ok(el))
} else {
match self.inner.process_complete().await {
Ok(resp) => match update_state(self.state, &resp) {
Ok(()) => None,
Err(e) => Some(Err(e)),
},
Err(e) => Some(Err(e)),
}
None
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ async fn execute_query(
}
}
Default => {
match print::native_to_stdout(items, &cfg).await {
match print::native_to_stdout(&mut items, &cfg).await {
Ok(()) => {}
Err(e) => {
match e {
Expand Down Expand Up @@ -503,6 +503,7 @@ async fn execute_query(
}
}
}
items.complete().await?;
if state.print_stats != Off {
eprintln!(
"{}",
Expand Down
3 changes: 2 additions & 1 deletion src/non_interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async fn _run_query(
stdout().lock().write_all(text.as_bytes())?;
}
}
OutputFormat::Default => match print::native_to_stdout(items, &cfg).await {
OutputFormat::Default => match print::native_to_stdout(&mut items, &cfg).await {
Ok(()) => {}
Err(e) => {
match e {
Expand Down Expand Up @@ -250,5 +250,6 @@ async fn _run_query(
}
}
}
let _ = items.complete().await?;
Ok(())
}

0 comments on commit 7e8dd93

Please sign in to comment.