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