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:
Access
2022-01-30 21:23:28 +08:00
committed by GitHub
parent 060a4b3f48
commit 1fd0ddb52c
2 changed files with 24 additions and 19 deletions

View File

@ -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)?;