File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
scylla-cql/src/deserialize Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,7 @@ where
120120 #[ inline]
121121 fn type_check ( typ : & ColumnType ) -> Result < ( ) , TypeCheckError > {
122122 <T as DeserializeValue < ' frame , ' metadata > >:: type_check ( typ)
123+ . map_err ( typck_error_replace_rust_name :: < Self > )
123124 }
124125
125126 fn deserialize (
@@ -130,7 +131,8 @@ where
130131 if val. is_empty ( ) {
131132 Ok ( MaybeEmpty :: Empty )
132133 } else {
133- let v = <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v) ?;
134+ let v = <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v)
135+ . map_err ( deser_error_replace_rust_name :: < Self > ) ?;
134136 Ok ( MaybeEmpty :: Value ( v) )
135137 }
136138 }
Original file line number Diff line number Diff line change @@ -1871,6 +1871,32 @@ fn test_option_errors() {
18711871 ) ;
18721872}
18731873
1874+ #[ test]
1875+ fn test_maybe_empty_errors ( ) {
1876+ // Type check correctly renames Rust type
1877+ assert_type_check_error ! (
1878+ & Bytes :: new( ) ,
1879+ MaybeEmpty <i32 >,
1880+ ColumnType :: Native ( NativeType :: Text ) ,
1881+ BuiltinTypeCheckErrorKind :: MismatchedType {
1882+ expected: & [ ColumnType :: Native ( NativeType :: Int ) ]
1883+ }
1884+ ) ;
1885+
1886+ // Deserialize correctly renames Rust type
1887+ let v = 123_i32 ;
1888+ let bytes = serialize ( & ColumnType :: Native ( NativeType :: Int ) , & v) ;
1889+ assert_deser_error ! (
1890+ & bytes,
1891+ MaybeEmpty <f64 >,
1892+ ColumnType :: Native ( NativeType :: Double ) ,
1893+ BuiltinDeserializationErrorKind :: ByteLengthMismatch {
1894+ expected: 8 ,
1895+ got: 4 ,
1896+ }
1897+ ) ;
1898+ }
1899+
18741900#[ test]
18751901fn test_set_or_list_errors ( ) {
18761902 // Not a set or list
You can’t perform that action at this time.
0 commit comments