From 568008dd47b03168eaea560552f5c82734c64358 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 16 Oct 2026 04:29:58 +0700 Subject: [PATCH] Variables: graph values go through the dataset CSV too (#1941) --- crates/engine/src/cmd/variablecmds.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/variablecmds.rs b/crates/engine/src/cmd/variablecmds.rs index 31cfff228..c3cc152fa 100644 --- a/crates/engine/src/cmd/variablecmds.rs +++ b/crates/engine/src/cmd/variablecmds.rs @@ -129,8 +129,7 @@ fn values_param(vars: &Variables, p: &Value, cmd: &str) -> Result Result { const C: &str = "variable.define"; let name = var_name(p, C)?; - let kind = - str_param(p, "kind").and_then(VariableKind::parse).ok_or_else(|| bad(C, "`kind` must be `text`, `visibility`, `image` or `graph`"))?; + let kind = str_param(p, "kind").and_then(VariableKind::parse).ok_or_else(|| bad(C, "`kind` must be `text`, `visibility`, `image` or `graph`"))?; if s.doc()?.doc.variables.variable(&name).is_some() { return Err(bad(C, format!("variable `{name}` is already defined"))); } @@ -598,13 +597,15 @@ fn cell_to_value(kind: VariableKind, cell: &str, var: &str, cmd: &str) -> Result Ok(Some(match kind { VariableKind::Text => DataValue::Text(t.to_string()), VariableKind::Image => DataValue::Image(t.to_string()), + VariableKind::Graph if t.len() <= MAX_GRAPH_CSV => DataValue::Graph(t.to_string()), + VariableKind::Graph => return Err(bad(cmd, format!("value for `{var}` is longer than {MAX_GRAPH_CSV} bytes"))), VariableKind::Visibility => DataValue::Visible(parse_visible_cell(t, var, cmd)?), })) } fn value_to_cell(v: &DataValue) -> String { match v { - DataValue::Text(t) | DataValue::Image(t) => t.clone(), + DataValue::Text(t) | DataValue::Image(t) | DataValue::Graph(t) => t.clone(), DataValue::Visible(b) => if *b { "true" } else { "false" }.to_string(), } }