From ac6143f685c3e83cad5ecfe33074bc0d0ceb067e Mon Sep 17 00:00:00 2001 From: Valerii Ponomarov Date: Thu, 24 Oct 2024 16:26:40 +0300 Subject: [PATCH] Fix blob function usage 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'. 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] https://github.com/pkolaczk/latte/pull/96 --- src/scripting/bind.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/scripting/bind.rs b/src/scripting/bind.rs index 3f32f75..38a6ddd 100644 --- a/src/scripting/bind.rs +++ b/src/scripting/bind.rs @@ -67,6 +67,13 @@ fn to_scylla_value(v: &Value, typ: &ColumnType) -> Result { } } (Value::Bytes(v), ColumnType::Blob) => Ok(CqlValue::Blob(v.borrow_ref().unwrap().to_vec())), + (Value::Vec(v), ColumnType::Blob) => { + let v: Vec = v.borrow_ref().unwrap().to_vec(); + let byte_vec: Vec = 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),