mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-24 10:46:50 -06:00
This commit is contained in:
@@ -86,8 +86,11 @@ fn key_of(v: &Value) -> String {
|
||||
fn row_key(r: &[Value]) -> String {
|
||||
let mut s = String::new();
|
||||
for v in r {
|
||||
s.push_str(&key_of(v));
|
||||
s.push('\u{1}');
|
||||
let k = key_of(v);
|
||||
// Length prefix keeps the encoding unambiguous even when a text value contains the separator.
|
||||
s.push_str(&k.len().to_string());
|
||||
s.push(':');
|
||||
s.push_str(&k);
|
||||
}
|
||||
s
|
||||
}
|
||||
@@ -1102,6 +1105,12 @@ mod tests {
|
||||
is_err(ev("SORTBY", vec![av(col(&[1.0, 2.0])), av(col(&[1.0, 2.0])), n(0.0)]), CellError::Value);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unique_keeps_rows_containing_separator_apart() {
|
||||
let m = arr(vec![vec![tv("a"), tv("b\u{1}tc")], vec![tv("a\u{1}tb"), tv("c")]]);
|
||||
assert_eq!(rows_of(&ev("UNIQUE", vec![av(m)])).len(), 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unique() {
|
||||
let v = arr(vec![vec![tv("a")], vec![tv("B")], vec![tv("A")], vec![tv("c")], vec![tv("b")]]);
|
||||
|
||||
Reference in New Issue
Block a user