File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed
scylla-cql/src/deserialize Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -666,13 +666,16 @@ where
666666{
667667 fn type_check ( typ : & ColumnType ) -> Result < ( ) , TypeCheckError > {
668668 <T as DeserializeValue < ' frame , ' metadata > >:: type_check ( typ)
669+ . map_err ( typck_error_replace_rust_name :: < Self > )
669670 }
670671
671672 fn deserialize (
672673 typ : & ' metadata ColumnType < ' metadata > ,
673674 v : Option < FrameSlice < ' frame > > ,
674675 ) -> Result < Self , DeserializationError > {
675- <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v) . map ( secrecy_08:: Secret :: new)
676+ <T as DeserializeValue < ' frame , ' metadata > >:: deserialize ( typ, v)
677+ . map ( secrecy_08:: Secret :: new)
678+ . map_err ( deser_error_replace_rust_name :: < Self > )
676679 }
677680}
678681
Original file line number Diff line number Diff line change @@ -1897,6 +1897,41 @@ fn test_maybe_empty_errors() {
18971897 ) ;
18981898}
18991899
1900+ #[ cfg( feature = "secrecy-08" ) ]
1901+ #[ test]
1902+ fn test_secrecy_08_errors ( ) {
1903+ use secrecy_08:: Secret ;
1904+
1905+ use crate :: frame:: frame_errors:: LowLevelDeserializationError ;
1906+ // Type check correctly renames Rust type
1907+ assert_type_check_error ! (
1908+ & Bytes :: new( ) ,
1909+ Secret <String >,
1910+ ColumnType :: Native ( NativeType :: Int ) ,
1911+ BuiltinTypeCheckErrorKind :: MismatchedType {
1912+ expected: & [
1913+ ColumnType :: Native ( NativeType :: Ascii ) ,
1914+ ColumnType :: Native ( NativeType :: Text )
1915+ ]
1916+ }
1917+ ) ;
1918+
1919+ // Deserialize correctly renames Rust type
1920+ let v = 123_i32 ;
1921+ let bytes = serialize ( & ColumnType :: Native ( NativeType :: Int ) , & v) ;
1922+ assert_deser_error ! (
1923+ & bytes,
1924+ Secret <Vec <String >>,
1925+ ColumnType :: Collection {
1926+ frozen: false ,
1927+ typ: CollectionType :: List ( Box :: new( ColumnType :: Native ( NativeType :: Text ) ) )
1928+ } ,
1929+ BuiltinDeserializationErrorKind :: RawCqlBytesReadError (
1930+ LowLevelDeserializationError :: IoError ( _)
1931+ )
1932+ ) ;
1933+ }
1934+
19001935#[ test]
19011936fn test_set_or_list_errors ( ) {
19021937 // Not a set or list
You can’t perform that action at this time.
0 commit comments