mirror of
https://github.com/OMGeeky/google_bigquery_v2.git
synced 2026-01-16 16:46:24 +01:00
better value-type matching in convert_bigquery_params.rs
This commit is contained in:
@@ -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)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user