mirror of
https://github.com/nushell/nushell.git
synced 2025-05-09 04:24:26 +02:00
refactor(cell-path): update constructors and call sites
This commit is contained in:
parent
0294419c76
commit
dec0f84623
@ -251,6 +251,7 @@ fn format_record(
|
||||
val: path.to_string(),
|
||||
span: *span,
|
||||
optional: false,
|
||||
insensitive: false,
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -63,6 +63,7 @@ impl Command for Reject {
|
||||
val: val.clone(),
|
||||
span: *col_span,
|
||||
optional: false,
|
||||
insensitive: false,
|
||||
}],
|
||||
};
|
||||
new_columns.push(cv.clone());
|
||||
|
@ -67,6 +67,7 @@ produce a table, a list will produce a list, and a record will produce a record.
|
||||
val,
|
||||
span: col_span,
|
||||
optional: false,
|
||||
insensitive: false,
|
||||
}],
|
||||
};
|
||||
new_columns.push(cv);
|
||||
|
@ -164,7 +164,14 @@ impl Command for Sort {
|
||||
if let Type::Table(cols) = r#type {
|
||||
let columns: Vec<Comparator> = cols
|
||||
.iter()
|
||||
.map(|col| vec![PathMember::string(col.0.clone(), false, Span::unknown())])
|
||||
.map(|col| {
|
||||
vec![PathMember::string(
|
||||
col.0.clone(),
|
||||
false,
|
||||
false,
|
||||
Span::unknown(),
|
||||
)]
|
||||
})
|
||||
.map(|members| CellPath { members })
|
||||
.map(Comparator::CellPath)
|
||||
.collect();
|
||||
|
@ -327,6 +327,7 @@ fn into_sqlite_big_insert() {
|
||||
val: "somedate".into(),
|
||||
span: Span::unknown(),
|
||||
optional: false,
|
||||
insensitive: false,
|
||||
}],
|
||||
Box::new(|dateval| {
|
||||
Value::string(dateval.coerce_string().unwrap(), dateval.span())
|
||||
|
@ -526,6 +526,7 @@ fn test_sort_equivalent() {
|
||||
val: "value".to_string(),
|
||||
span: Span::test_data(),
|
||||
optional: false,
|
||||
insensitive: false,
|
||||
}],
|
||||
});
|
||||
|
||||
|
@ -585,6 +585,7 @@ impl FromValue for CellPath {
|
||||
val,
|
||||
span,
|
||||
optional: false,
|
||||
insensitive: false,
|
||||
}],
|
||||
}),
|
||||
Value::Int { val, .. } => {
|
||||
|
@ -1373,6 +1373,7 @@ impl Value {
|
||||
val: col_name,
|
||||
span,
|
||||
optional,
|
||||
insensitive,
|
||||
} => match self {
|
||||
Value::List { vals, .. } => {
|
||||
for val in vals.iter_mut() {
|
||||
@ -1448,6 +1449,7 @@ impl Value {
|
||||
val: col_name,
|
||||
span,
|
||||
optional,
|
||||
insensitive,
|
||||
} => match self {
|
||||
Value::List { vals, .. } => {
|
||||
for val in vals.iter_mut() {
|
||||
@ -2092,6 +2094,7 @@ fn get_value_member<'a>(
|
||||
val: column_name,
|
||||
span: origin_span,
|
||||
optional,
|
||||
insensitive,
|
||||
} => {
|
||||
let span = current.span();
|
||||
match current {
|
||||
@ -4100,10 +4103,10 @@ mod tests {
|
||||
assert_eq!(
|
||||
Value::with_data_at_cell_path(
|
||||
&[
|
||||
PathMember::test_string("a".to_string(), false),
|
||||
PathMember::test_string("b".to_string(), false),
|
||||
PathMember::test_string("c".to_string(), false),
|
||||
PathMember::test_string("d".to_string(), false),
|
||||
PathMember::test_string("a".to_string(), false, false),
|
||||
PathMember::test_string("b".to_string(), false, false),
|
||||
PathMember::test_string("c".to_string(), false, false),
|
||||
PathMember::test_string("d".to_string(), false, false),
|
||||
],
|
||||
value_to_insert,
|
||||
),
|
||||
@ -4147,13 +4150,13 @@ mod tests {
|
||||
assert_eq!(
|
||||
Value::with_data_at_cell_path(
|
||||
&[
|
||||
PathMember::test_string("a".to_string(), false),
|
||||
PathMember::test_string("a".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
PathMember::test_string("b".to_string(), false),
|
||||
PathMember::test_string("b".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
PathMember::test_string("c".to_string(), false),
|
||||
PathMember::test_string("c".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
PathMember::test_string("d".to_string(), false),
|
||||
PathMember::test_string("d".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
],
|
||||
value_to_insert.clone(),
|
||||
@ -4183,9 +4186,9 @@ mod tests {
|
||||
let value_to_insert = Value::test_string("value");
|
||||
let res = base_value.upsert_data_at_cell_path(
|
||||
&[
|
||||
PathMember::test_string("a".to_string(), false),
|
||||
PathMember::test_string("a".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
PathMember::test_string("b".to_string(), false),
|
||||
PathMember::test_string("b".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
],
|
||||
value_to_insert.clone(),
|
||||
@ -4217,9 +4220,9 @@ mod tests {
|
||||
let value_to_insert = Value::test_string("value");
|
||||
let res = base_value.insert_data_at_cell_path(
|
||||
&[
|
||||
PathMember::test_string("a".to_string(), false),
|
||||
PathMember::test_string("a".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
PathMember::test_string("b".to_string(), false),
|
||||
PathMember::test_string("b".to_string(), false, false),
|
||||
PathMember::test_int(0, false),
|
||||
],
|
||||
value_to_insert.clone(),
|
||||
|
@ -396,8 +396,8 @@ mod tests {
|
||||
r#"$.foo.bar.0"#,
|
||||
Some(Value::test_cell_path(CellPath {
|
||||
members: vec![
|
||||
PathMember::string("foo".to_string(), false, Span::new(2, 5)),
|
||||
PathMember::string("bar".to_string(), false, Span::new(6, 9)),
|
||||
PathMember::string("foo".to_string(), false, false, Span::new(2, 5)),
|
||||
PathMember::string("bar".to_string(), false, false, Span::new(6, 9)),
|
||||
PathMember::int(0, false, Span::new(10, 11)),
|
||||
],
|
||||
})),
|
||||
|
Loading…
Reference in New Issue
Block a user