From a5ac1884c135e2fcb417a3809c2ca13f07aad50f Mon Sep 17 00:00:00 2001 From: Luca Muscat Date: Mon, 16 Jun 2025 20:24:40 +0200 Subject: [PATCH] core: Stop treating the contents of a `Value::Blob` as a String By encoding a Vec (vector of bytes), a lossy conversion from a `Vec` to a `String` occurs. The lossy conversion leads to an incorrect hex value to be displayed. Avoid the lossy conversion and let the `hex` crate do its thing. --- core/vdbe/execute.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 3f82581be..b344e9126 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -5792,10 +5792,11 @@ impl Value { pub fn exec_hex(&self) -> Value { match self { - Value::Text(_) | Value::Integer(_) | Value::Float(_) | Value::Blob(_) => { + Value::Text(_) | Value::Integer(_) | Value::Float(_) => { let text = self.to_string(); Value::build_text(&hex::encode_upper(text)) } + Value::Blob(blob_bytes) => Value::build_text(&hex::encode_upper(blob_bytes)), _ => Value::Null, } } @@ -7548,6 +7549,10 @@ mod tests { let input_float = Value::Float(12.34); let expected_val = Value::build_text("31322E3334"); assert_eq!(input_float.exec_hex(), expected_val); + + let input_blob = Value::Blob(vec![0xff]); + let expected_val = Value::build_text("FF"); + assert_eq!(input_blob.exec_hex(), expected_val); } #[test]