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
|
/target
|
||||||
/.idea
|
/.idea
|
||||||
/auth
|
/auth
|
||||||
|
/Cargo.lock
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "google_bigquery_v2"
|
name = "google_bigquery_v2"
|
||||||
version = "0.2.2"
|
version = "0.2.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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 std::fmt::Debug;
|
||||||
|
|
||||||
use chrono::{NaiveDateTime, Utc};
|
use chrono::{NaiveDateTime, Utc};
|
||||||
use crate::prelude::*;
|
|
||||||
use serde_json::{value, Value};
|
use serde_json::{value, Value};
|
||||||
|
|
||||||
use crate::prelude::*;
|
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");
|
trace!("ConvertValueToBigqueryParamValue::convert_value_type_to_bigquery_type: String");
|
||||||
Ok(value::from_value(value)?)
|
Ok(value::from_value(value)?)
|
||||||
} else {
|
} else {
|
||||||
warn!("Unknown type: {:?}", value);
|
match value {
|
||||||
if value == Value::Null {
|
Value::Null => Err("Value is Null".into()),
|
||||||
return 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