Skip to content

Commit f2c505e

Browse files
committed
Remark CoPilot
1 parent 90a6b65 commit f2c505e

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

dsc_lib/src/functions/join.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ use tracing::debug;
1212
pub struct Join {}
1313

1414
fn stringify_value(v: &Value) -> String {
15-
if let Some(s) = v.as_str() { return s.to_string(); }
16-
if let Some(n) = v.as_i64() { return n.to_string(); }
17-
if let Some(b) = v.as_bool() { return b.to_string(); }
18-
if v.is_null() { return "null".to_string(); }
19-
// Fallback to JSON for arrays/objects or other numbers
20-
serde_json::to_string(v).unwrap_or_default()
15+
match v {
16+
Value::String(s) => s.clone(),
17+
Value::Number(n) => n.to_string(),
18+
Value::Bool(b) => b.to_string(),
19+
Value::Null => "null".to_string(),
20+
// Fallback to JSON for arrays/objects
21+
_ => serde_json::to_string(v).unwrap_or_default(),
22+
}
2123
}
2224

2325
impl Function for Join {
@@ -77,4 +79,11 @@ mod tests {
7779
let result = parser.parse_and_execute("[join(createArray(), '-')]", &Context::new()).unwrap();
7880
assert_eq!(result, "");
7981
}
82+
83+
#[test]
84+
fn join_array_of_floats() {
85+
let mut parser = Statement::new().unwrap();
86+
let result = parser.parse_and_execute("[join(createArray(1.5,2.5,3.0), ',')]", &Context::new()).unwrap();
87+
assert_eq!(result, "1.5,2.5,3.0");
88+
}
8089
}

0 commit comments

Comments
 (0)