Skip to content

Commit 894eab8

Browse files
committed
deserialize: Fix rust name in type check for sets
Impls for BTreeSet and HashSet had a bug: they performed type check on element, but then renamed the rust name in error to container type (while cql type remained the element type). Such errors are obviously incorrect. There are 2 ways to fix it. I'll let the reviewer choos which we should use: - Performing type check on element, then wrapping the error (this is the same thing that ListLikeIterator does). - Calling type check of ListLikeIterator - shorter and prettier code, but performs the same check twice (probably would be optimized out by compiler). I chose this solution for now because it is consistent with Vec and avoids code duplication.
1 parent 04bf68e commit 894eab8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scylla-cql/src/deserialize/value.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,8 @@ where
880880
match typ {
881881
ColumnType::Collection {
882882
frozen: false,
883-
typ: CollectionType::Set(el_t),
884-
} => <T as DeserializeValue<'frame, 'metadata>>::type_check(el_t)
883+
typ: CollectionType::Set(_),
884+
} => ListlikeIterator::<'frame, 'metadata, T>::type_check(typ)
885885
.map_err(typck_error_replace_rust_name::<Self>),
886886
_ => Err(mk_typck_err::<Self>(
887887
typ,
@@ -911,8 +911,8 @@ where
911911
match typ {
912912
ColumnType::Collection {
913913
frozen: false,
914-
typ: CollectionType::Set(el_t),
915-
} => <T as DeserializeValue<'frame, 'metadata>>::type_check(el_t)
914+
typ: CollectionType::Set(_),
915+
} => ListlikeIterator::<'frame, 'metadata, T>::type_check(typ)
916916
.map_err(typck_error_replace_rust_name::<Self>),
917917
_ => Err(mk_typck_err::<Self>(
918918
typ,

0 commit comments

Comments
 (0)