From 296391964949386b93591f4ef436aa255e952130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Fern=C3=A1ndez?= Date: Wed, 8 Nov 2023 13:50:44 +0100 Subject: [PATCH] fix: Use fractionals in PS Datetimes (#4426) * Use fractionals in PS Datetimes * Update mysql.rs --- query-engine/driver-adapters/src/conversion/mysql.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/query-engine/driver-adapters/src/conversion/mysql.rs b/query-engine/driver-adapters/src/conversion/mysql.rs index ed596364a36b..aab33213431a 100644 --- a/query-engine/driver-adapters/src/conversion/mysql.rs +++ b/query-engine/driver-adapters/src/conversion/mysql.rs @@ -1,9 +1,9 @@ use crate::conversion::JSArg; use serde_json::value::Value as JsonValue; -const DATETIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S"; +const DATETIME_FORMAT: &str = "%Y-%m-%d %H:%M:%S%.f"; const DATE_FORMAT: &str = "%Y-%m-%d"; -const TIME_FORMAT: &str = "%H:%M:%S"; +const TIME_FORMAT: &str = "%H:%M:%S%.f"; #[rustfmt::skip] pub fn value_to_js_arg(value: &quaint::Value) -> serde_json::Result { @@ -66,16 +66,16 @@ mod test { JSArg::Value(JsonValue::Null) ), ( - ValueType::DateTime(Some(Utc.with_ymd_and_hms(2020, 1, 1, 23, 13, 1).unwrap())), - JSArg::Value(JsonValue::String("2020-01-01 23:13:01".to_string())) + ValueType::DateTime(Some(Utc.with_ymd_and_hms(2020, 1, 1, 23, 13, 1).unwrap().with_nanosecond(100).unwrap())), + JSArg::Value(JsonValue::String("2020-01-01 23:13:01.000000100".to_string())) ), ( ValueType::DateTime(None), JSArg::Value(JsonValue::Null) ), ( - ValueType::Time(Some(NaiveTime::from_hms_opt(23, 13, 1).unwrap())), - JSArg::Value(JsonValue::String("23:13:01".to_string())) + ValueType::Time(Some(NaiveTime::from_hms_opt(23, 13, 1).unwrap().with_nanosecond(1200).unwrap())), + JSArg::Value(JsonValue::String("23:13:01.000001200".to_string())) ), ( ValueType::Time(None),