@@ -9,8 +9,10 @@ pub enum Value<'a> {
99 I64 ( i64 ) ,
1010 F32 ( f32 ) ,
1111 F64 ( f64 ) ,
12- Char ( & ' a str ) ,
12+ Timestamp ( i64 ) ,
13+ String ( & ' a str ) ,
1314 Binary ( & ' a [ u8 ] ) ,
15+ Bool ( bool ) ,
1416}
1517
1618impl Display for Value < ' _ > {
@@ -23,8 +25,10 @@ impl Display for Value<'_> {
2325 Value :: I64 ( v) => write ! ( f, "{}" , v) ,
2426 Value :: F32 ( v) => write ! ( f, "{}" , v) ,
2527 Value :: F64 ( v) => write ! ( f, "{}" , v) ,
26- Value :: Char ( v) => write ! ( f, "{}" , v) ,
28+ Value :: Timestamp ( v) => write ! ( f, "{}" , v) ,
29+ Value :: String ( v) => write ! ( f, "{}" , v) ,
2730 Value :: Binary ( v) => write ! ( f, "{:?}" , v) ,
31+ Value :: Bool ( v) => write ! ( f, "{}" , v) ,
2832 }
2933 }
3034}
@@ -45,14 +49,19 @@ impl<'a> Value<'a> {
4549 DataType :: BigInt => Value :: I64 ( xdb_column_int64 ( meta, row, col) ) ,
4650 DataType :: Float => Value :: F32 ( xdb_column_float ( meta, row, col) ) ,
4751 DataType :: Double => Value :: F64 ( xdb_column_double ( meta, row, col) ) ,
52+ DataType :: Timestamp => Value :: Timestamp ( xdb_column_int64 ( meta, row, col) ) ,
4853 DataType :: Char | DataType :: VChar => {
49- let s = CStr :: from_ptr ( xdb_column_str ( meta, row, col) ) ;
50- Value :: Char ( s. to_str ( ) . unwrap ( ) )
54+ let ptr = xdb_column_str ( meta, row, col) ;
55+ if ptr. is_null ( ) {
56+ return Value :: Null ;
57+ }
58+ Value :: String ( CStr :: from_ptr ( ptr) . to_str ( ) . unwrap ( ) )
5159 }
5260 DataType :: Binary | DataType :: VBinary => {
5361 // xdb_column_blob(meta, row, col, pLen);
5462 todo ! ( )
5563 }
64+ DataType :: Bool => Value :: Bool ( xdb_column_int ( meta, row, col) == 1 ) ,
5665 _ => unimplemented ! ( ) ,
5766 }
5867 }
0 commit comments