From 10ecf5672d60461043b7c4d35552c425a043d28b Mon Sep 17 00:00:00 2001 From: bitful-pannul Date: Thu, 18 Jul 2024 20:55:17 +0200 Subject: [PATCH] sqlite: fix potential nullable columns read --- kinode/src/sqlite.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kinode/src/sqlite.rs b/kinode/src/sqlite.rs index dec0145c..6608723c 100644 --- a/kinode/src/sqlite.rs +++ b/kinode/src/sqlite.rs @@ -203,14 +203,14 @@ async fn handle_request( .query_map(rusqlite::params_from_iter(parameters.iter()), |row| { let mut map = HashMap::new(); for (i, column_name) in column_names.iter().enumerate() { - let value: SqlValue = row.get(i)?; + let value: Option = row.get(i)?; let value_json = match value { - SqlValue::Integer(int) => serde_json::Value::Number(int.into()), - SqlValue::Real(real) => serde_json::Value::Number( + Some(SqlValue::Integer(int)) => serde_json::Value::Number(int.into()), + Some(SqlValue::Real(real)) => serde_json::Value::Number( serde_json::Number::from_f64(real).unwrap(), ), - SqlValue::Text(text) => serde_json::Value::String(text), - SqlValue::Blob(blob) => { + Some(SqlValue::Text(text)) => serde_json::Value::String(text), + Some(SqlValue::Blob(blob)) => { serde_json::Value::String(base64_standard.encode(blob)) } // or another representation if you prefer _ => serde_json::Value::Null,