Skip to content

Commit

Permalink
Fix blob function usage
Browse files Browse the repository at this point in the history
In the PR [1] with the switch from 'rune-0.12' to 'rune-0.13'
the 'blob' function changed it's return type from 'rune::runtime::Bytes'
to the 'Vec<u8>'.
Such a change required also an update to the input values parser
to expect one more input type match to the 'ColumnType::Blob'.

So, add the missing parsing element to make the 'blob' function work
again as it was before.
It will allow to avoid manual wrapping into the
'rune::runtime::Bytes' type in rune scripts.

[1] #96
  • Loading branch information
vponomaryov committed Nov 15, 2024
1 parent 188b8dc commit 6c771a2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/scripting/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ fn to_scylla_value(v: &Value, typ: &ColumnType) -> Result<CqlValue, CassError> {
}
}
(Value::Bytes(v), ColumnType::Blob) => Ok(CqlValue::Blob(v.borrow_ref().unwrap().to_vec())),
(Value::Vec(v), ColumnType::Blob) => {
let v: Vec<Value> = v.borrow_ref().unwrap().to_vec();
let byte_vec: Vec<u8> = v
.into_iter()
.map(|value| value.as_byte().unwrap())
.collect();
Ok(CqlValue::Blob(byte_vec))
}
(Value::Option(v), typ) => match v.borrow_ref().unwrap().as_ref() {
Some(v) => to_scylla_value(v, typ),
None => Ok(CqlValue::Empty),
Expand Down

0 comments on commit 6c771a2

Please sign in to comment.