@@ -59,6 +59,7 @@ const SECONDS_PER_DAY: u64 = 60 * 60 * 24;
5959#[ non_exhaustive]
6060pub enum Value {
6161 Void ,
62+ Null ,
6263 Bool ( bool ) ,
6364 Int8 ( i8 ) ,
6465 Uint8 ( u8 ) ,
@@ -280,6 +281,7 @@ impl Value {
280281 _ => unimplemented ! ( "{:?} ({})" , P :: from_i32( * t_id) , * t_id) ,
281282 } ,
282283 T :: VoidType ( _) => Value :: Void ,
284+ T :: NullType ( _) => Value :: Null ,
283285 T :: OptionalType ( val) => {
284286 let t = if let Some ( item) = & val. item {
285287 Some ( * item. clone ( ) )
@@ -319,6 +321,7 @@ impl Value {
319321 pub ( crate ) fn from_proto ( t : & Value , proto_value : ydb_proto:: Value ) -> YdbResult < Self > {
320322 let res = match ( t, proto_value) {
321323 ( Value :: Void , _) => Value :: Void ,
324+ ( Value :: Null , _) => Value :: Null ,
322325 (
323326 t,
324327 ydb_proto:: Value {
@@ -461,6 +464,21 @@ impl Value {
461464 ..ydb_proto:: Value :: default ( )
462465 } ) ,
463466 } ,
467+ Self :: Null => ydb_proto:: TypedValue {
468+ r#type : Some ( ydb_proto:: Type {
469+ r#type : Some ( ydb_proto:: r#type:: Type :: NullType (
470+ prost_types:: NullValue :: NullValue . into ( ) ,
471+ ) ) ,
472+ ..ydb_proto:: Type :: default ( )
473+ } ) ,
474+ value : Some ( ydb_proto:: Value {
475+ value : Some ( ydb_proto:: value:: Value :: NullFlagValue (
476+ prost_types:: NullValue :: NullValue . into ( ) ,
477+ ) ) ,
478+ ..ydb_proto:: Value :: default ( )
479+ } ) ,
480+ ..ydb_proto:: TypedValue :: default ( )
481+ } ,
464482 Self :: Bool ( val) => proto_typed_value ( pt:: Bool , pv:: BoolValue ( val) ) ,
465483 Self :: Int8 ( val) => proto_typed_value ( pt:: Int8 , pv:: Int32Value ( val. into ( ) ) ) ,
466484 Self :: Uint8 ( val) => proto_typed_value ( pt:: Uint8 , pv:: Uint32Value ( val. into ( ) ) ) ,
@@ -627,6 +645,7 @@ mod test {
627645 num_tests ! ( values, Value :: Double , f64 ) ;
628646
629647 values. push ( Value :: Void ) ;
648+ values. push ( Value :: Null ) ;
630649
631650 values. push ( Value :: Date ( std:: time:: Duration :: from_secs ( 1633996800 ) ) ) ; //Tue Oct 12 00:00:00 UTC 2021
632651 values. push ( Value :: DateTime ( std:: time:: Duration :: from_secs ( 1634000523 ) ) ) ; //Tue Oct 12 01:02:03 UTC 2021
0 commit comments