change map_err_without_data to return an Ok result on an empty Vec<T>

This commit is contained in:
OMGeeky
2023-06-06 18:42:29 +02:00
parent 82c262600d
commit 2249ec74c0
2 changed files with 12 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "google_bigquery_v2"
version = "0.2.6"
version = "0.2.7"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -57,12 +57,17 @@ impl<T: Debug> QueryResultType<T> {
pub fn map_err_without_data(self, message: impl Into<String>) -> Result<()> {
match self {
QueryResultType::WithoutRowData(result) => result,
QueryResultType::WithRowData(data) => Err(format!(
"map_err_without_data message:'{}' data: {:?}",
message.into(),
data
)
.into()),
QueryResultType::WithRowData(data) => {
if data.len() == 0 {
return Ok(());
}
return Err(format!(
"map_err_without_data message:'{}' data: {:?}",
message.into(),
data
)
.into());
}
}
}
pub fn expect_with_data(self, message: impl Into<String>) -> Vec<T> {