mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Maybe solve the none bug? (#860)
* Maybe solve the none bug? * cargo fmt * use nothing, not string * check at last * I check it at last * Use error which has span * use not found error * fix error * use a empty value length? * * Add commit about what I change and fmt Now all test passed, but I do not know if it is right * update the test * check if it is nothing * update commit * Rename test Co-authored-by: Jakub Žádník <kubouch@gmail.com>
This commit is contained in:
@ -632,24 +632,28 @@ impl Value {
|
||||
}
|
||||
Value::List { vals, span } => {
|
||||
let mut output = vec![];
|
||||
let mut hasvalue = false;
|
||||
let mut temp: Result<Value, ShellError> = Err(ShellError::NotFound(*span));
|
||||
for val in vals {
|
||||
output.push(val.clone().follow_cell_path(&[PathMember::String {
|
||||
temp = val.clone().follow_cell_path(&[PathMember::String {
|
||||
val: column_name.clone(),
|
||||
span: *origin_span,
|
||||
}])?);
|
||||
// if let Value::Record { cols, vals, .. } = val {
|
||||
// for col in cols.iter().enumerate() {
|
||||
// if col.1 == column_name {
|
||||
// output.push(vals[col.0].clone());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}]);
|
||||
if let Ok(result) = temp.clone() {
|
||||
hasvalue = true;
|
||||
output.push(result);
|
||||
} else {
|
||||
output.push(Value::Nothing { span: *span });
|
||||
}
|
||||
}
|
||||
if hasvalue {
|
||||
current = Value::List {
|
||||
vals: output,
|
||||
span: *span,
|
||||
};
|
||||
} else {
|
||||
return temp;
|
||||
}
|
||||
|
||||
current = Value::List {
|
||||
vals: output,
|
||||
span: *span,
|
||||
};
|
||||
}
|
||||
Value::CustomValue { val, .. } => {
|
||||
current = val.follow_path_string(column_name.clone(), *origin_span)?;
|
||||
|
Reference in New Issue
Block a user