Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tokio-postgres/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,15 @@ where

loop {
match responses.next().await? {
Message::ParseComplete
| Message::BindComplete
| Message::ParameterDescription(_)
| Message::NoData => {}
Message::ParseComplete | Message::BindComplete | Message::ParameterDescription(_) => {}
Message::NoData => {
return Ok(RowStream {
statement: Statement::unnamed(vec![], vec![]),
responses,
rows_affected: None,
_p: PhantomPinned,
});
}
Message::RowDescription(row_description) => {
let mut columns: Vec<Column> = vec![];
let mut it = row_description.fields();
Expand Down
14 changes: 14 additions & 0 deletions tokio-postgres/tests/test/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,13 @@ async fn query_typed_no_transaction() {
assert_eq!(second_row.get::<_, i32>(1), 40);
assert_eq!(second_row.get::<_, &str>(2), "literal");
assert_eq!(second_row.get::<_, i32>(3), 5);

// Test for UPDATE that returns no data
let updated_rows = client
.query_typed("UPDATE foo set age = 33", &[])
.await
.unwrap();
assert_eq!(updated_rows.len(), 0);
}

#[tokio::test]
Expand Down Expand Up @@ -1064,4 +1071,11 @@ async fn query_typed_with_transaction() {
assert_eq!(second_row.get::<_, i32>(1), 40);
assert_eq!(second_row.get::<_, &str>(2), "literal");
assert_eq!(second_row.get::<_, i32>(3), 5);

// Test for UPDATE that returns no data
let updated_rows = transaction
.query_typed("UPDATE foo set age = 33", &[])
.await
.unwrap();
assert_eq!(updated_rows.len(), 0);
}