Skip to content

Commit 4de9669

Browse files
committed
from_row: test case for unnamed fields
1 parent 4909d7e commit 4de9669

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

scylla-cql/src/frame/response/cql_to_rust.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,4 +1000,24 @@ mod tests {
10001000
})
10011001
);
10021002
}
1003+
1004+
#[test]
1005+
fn unnamed_struct_from_row() {
1006+
#[derive(FromRow)]
1007+
struct MyRow(i32, Option<String>, Option<Vec<i32>>);
1008+
1009+
let row = Row {
1010+
columns: vec![
1011+
Some(CqlValue::Int(16)),
1012+
None,
1013+
Some(CqlValue::Set(vec![CqlValue::Int(1), CqlValue::Int(2)])),
1014+
],
1015+
};
1016+
1017+
let my_row: MyRow = MyRow::from_row(row).unwrap();
1018+
1019+
assert_eq!(my_row.0, 16);
1020+
assert_eq!(my_row.1, None);
1021+
assert_eq!(my_row.2, Some(vec![1, 2]));
1022+
}
10031023
}

0 commit comments

Comments
 (0)