mirror of
https://github.com/OMGeeky/google_bigquery_v2.git
synced 2025-12-26 16:17:24 +01:00
better value-type matching in convert_bigquery_params.rs
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
/target
|
||||
/.idea
|
||||
/auth
|
||||
/Cargo.lock
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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