@@ -27,13 +27,13 @@ pub fn transform_value(value: DBResponseValue, type_: &str) -> DBResponsePrimiti
2727 match value {
2828 DBResponseValue :: DateTime ( dt) if type_ == "time" || type_. is_empty ( ) => {
2929 let formatted = dt. to_rfc3339_opts ( SecondsFormat :: Millis , true ) ;
30- DBResponsePrimitive :: String ( formatted)
30+ DBResponsePrimitive :: String ( formatted. trim_end_matches ( 'Z' ) . to_string ( ) )
3131 }
3232 DBResponseValue :: Primitive ( DBResponsePrimitive :: String ( ref s) ) if type_ == "time" => {
3333 let formatted = DateTime :: parse_from_rfc3339 ( s)
3434 . map ( |dt| dt. to_rfc3339_opts ( SecondsFormat :: Millis , true ) )
3535 . unwrap_or_else ( |_| s. clone ( ) ) ;
36- DBResponsePrimitive :: String ( formatted)
36+ DBResponsePrimitive :: String ( formatted. trim_end_matches ( 'Z' ) . to_string ( ) )
3737 }
3838 DBResponseValue :: Primitive ( p) => p,
3939 DBResponseValue :: Object { value } => value,
@@ -272,6 +272,8 @@ pub fn get_vanilla_row(
272272 . unwrap_or ( & "" . to_string ( ) ) ,
273273 ) ;
274274
275+ row. insert ( member_name. clone ( ) , transformed_value. clone ( ) ) ;
276+
275277 // Handle deprecated time dimensions without granularity
276278 let path: Vec < & str > = member_name. split ( MEMBER_SEPARATOR ) . collect ( ) ;
277279 let member_name_without_granularity =
@@ -284,8 +286,6 @@ pub fn get_vanilla_row(
284286 } )
285287 {
286288 row. insert ( member_name_without_granularity, transformed_value) ;
287- } else {
288- row. insert ( member_name. clone ( ) , transformed_value) ;
289289 }
290290 }
291291 }
@@ -605,12 +605,13 @@ impl Display for DBResponseValue {
605605#[ cfg( test) ]
606606mod tests {
607607 use super :: * ;
608- use chrono:: { TimeZone , Utc , Timelike } ;
609608 use anyhow:: Result ;
609+ use chrono:: { TimeZone , Timelike , Utc } ;
610610
611611 #[ test]
612612 fn test_transform_value_datetime_to_time ( ) {
613- let dt = Utc . with_ymd_and_hms ( 2024 , 1 , 1 , 12 , 30 , 15 )
613+ let dt = Utc
614+ . with_ymd_and_hms ( 2024 , 1 , 1 , 12 , 30 , 15 )
614615 . unwrap ( )
615616 . with_nanosecond ( 123_000_000 )
616617 . unwrap ( ) ;
@@ -619,13 +620,14 @@ mod tests {
619620
620621 assert_eq ! (
621622 result,
622- DBResponsePrimitive :: String ( "2024-01-01T12:30:15.123Z " . to_string( ) )
623+ DBResponsePrimitive :: String ( "2024-01-01T12:30:15.123 " . to_string( ) )
623624 ) ;
624625 }
625626
626627 #[ test]
627628 fn test_transform_value_datetime_empty_type ( ) {
628- let dt = Utc . with_ymd_and_hms ( 2024 , 1 , 1 , 12 , 30 , 15 )
629+ let dt = Utc
630+ . with_ymd_and_hms ( 2024 , 1 , 1 , 12 , 30 , 15 )
629631 . unwrap ( )
630632 . with_nanosecond ( 123_000_000 )
631633 . unwrap ( ) ;
@@ -634,28 +636,27 @@ mod tests {
634636
635637 assert_eq ! (
636638 result,
637- DBResponsePrimitive :: String ( "2024-01-01T12:30:15.123Z " . to_string( ) )
639+ DBResponsePrimitive :: String ( "2024-01-01T12:30:15.123 " . to_string( ) )
638640 ) ;
639641 }
640642
641643 #[ test]
642644 fn test_transform_value_string_to_time_valid_rfc3339 ( ) {
643645 let value = DBResponseValue :: Primitive ( DBResponsePrimitive :: String (
644- "2024-01-01T12:30:15.123Z " . to_string ( ) ,
646+ "2024-01-01T12:30:15.123 " . to_string ( ) ,
645647 ) ) ;
646648 let result = transform_value ( value, "time" ) ;
647649
648650 assert_eq ! (
649651 result,
650- DBResponsePrimitive :: String ( "2024-01-01T12:30:15.123Z " . to_string( ) )
652+ DBResponsePrimitive :: String ( "2024-01-01T12:30:15.123 " . to_string( ) )
651653 ) ;
652654 }
653655
654656 #[ test]
655657 fn test_transform_value_string_to_time_invalid_rfc3339 ( ) {
656- let value = DBResponseValue :: Primitive ( DBResponsePrimitive :: String (
657- "invalid-date" . to_string ( ) ,
658- ) ) ;
658+ let value =
659+ DBResponseValue :: Primitive ( DBResponsePrimitive :: String ( "invalid-date" . to_string ( ) ) ) ;
659660 let result = transform_value ( value, "time" ) ;
660661
661662 assert_eq ! (
@@ -666,9 +667,8 @@ mod tests {
666667
667668 #[ test]
668669 fn test_transform_value_primitive_string_type_not_time ( ) {
669- let value = DBResponseValue :: Primitive ( DBResponsePrimitive :: String (
670- "some-string" . to_string ( ) ,
671- ) ) ;
670+ let value =
671+ DBResponseValue :: Primitive ( DBResponsePrimitive :: String ( "some-string" . to_string ( ) ) ) ;
672672 let result = transform_value ( value, "other" ) ;
673673
674674 assert_eq ! (
@@ -680,7 +680,9 @@ mod tests {
680680 #[ test]
681681 fn test_transform_value_object ( ) {
682682 let obj_value = DBResponsePrimitive :: String ( "object-value" . to_string ( ) ) ;
683- let value = DBResponseValue :: Object { value : obj_value. clone ( ) } ;
683+ let value = DBResponseValue :: Object {
684+ value : obj_value. clone ( ) ,
685+ } ;
684686 let result = transform_value ( value, "time" ) ;
685687
686688 assert_eq ! ( result, obj_value) ;
@@ -891,5 +893,4 @@ mod tests {
891893 )
892894 ) ;
893895 }
894-
895896}
0 commit comments