From 6c771a2bbc420dd5472d36a852e87071e3d88d77 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/scripting/bind.rs b/src/scripting/bind.rs index 3f32f75..004c6c3 100644 --- a/src/scripting/bind.rs +++ b/src/scripting/bind.rs @@ -67,6 +67,14 @@ 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),