better value-type matching in convert_bigquery_params.rs

This commit is contained in:
OMGeeky
2023-06-03 12:51:49 +02:00
parent 70e9cd559b
commit cda64f8fbb
3 changed files with 11 additions and 9 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/target
/.idea
/auth
/Cargo.lock

View File

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

View File

@@ -1,7 +1,6 @@
use std::fmt::Debug;
use chrono::{NaiveDateTime, Utc};
use crate::prelude::*;
use serde_json::{value, Value};
use crate::prelude::*;
@@ -138,13 +137,15 @@ pub fn convert_value_to_string(value: Value) -> Result<String> {
trace!("ConvertValueToBigqueryParamValue::convert_value_type_to_bigquery_type: String");
Ok(value::from_value(value)?)
} else {
warn!("Unknown type: {:?}", value);
if value == Value::Null {
return Err("Value is Null".into());
match value {
Value::Null => Err("Value is Null".into()),
Value::Number(num) => Ok(num.to_string()),
Value::String(s) => Ok(s),
_ => {
warn!("Unknown type: {:?}", value);
//TODO: check if this is correct with for example 'DATETIME' values
Ok(value.to_string())
}
}
//TODO: check if this is correct with for example 'DATETIME' values
// Err(format!("Unknown type: {:?}", value).into())
let string = value.to_string();
Ok(string)
};
}