mirror of
https://github.com/nushell/nushell.git
synced 2025-04-25 13:48:19 +02:00
# Description Makes `LazyRecord`s have the same error message as regular `Records` for `Value::follow_cell_path`. Fixes #11750.
This commit is contained in:
parent
9fa2b77611
commit
857c522808
@ -976,7 +976,7 @@ impl Value {
|
|||||||
}
|
}
|
||||||
// Records (and tables) are the only built-in which support column names,
|
// Records (and tables) are the only built-in which support column names,
|
||||||
// so only use this message for them.
|
// so only use this message for them.
|
||||||
Value::Record { .. } => {
|
Value::Record { .. } | Value::LazyRecord { .. } => {
|
||||||
return Err(ShellError::TypeMismatch {
|
return Err(ShellError::TypeMismatch {
|
||||||
err_message:"Can't access record values with a row index. Try specifying a column name instead".into(),
|
err_message:"Can't access record values with a row index. Try specifying a column name instead".into(),
|
||||||
span: *origin_span,
|
span: *origin_span,
|
||||||
@ -1202,9 +1202,8 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Value::LazyRecord { val, .. } => {
|
Value::LazyRecord { val, .. } => {
|
||||||
// convert to Record first.
|
// convert to Record first.
|
||||||
let mut record = val.collect()?;
|
*self = val.collect()?;
|
||||||
record.upsert_data_at_cell_path(cell_path, new_val)?;
|
self.upsert_data_at_cell_path(cell_path, new_val)?;
|
||||||
*self = record;
|
|
||||||
}
|
}
|
||||||
Value::Error { error, .. } => return Err(*error.clone()),
|
Value::Error { error, .. } => return Err(*error.clone()),
|
||||||
v => {
|
v => {
|
||||||
@ -1319,9 +1318,8 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Value::LazyRecord { val, .. } => {
|
Value::LazyRecord { val, .. } => {
|
||||||
// convert to Record first.
|
// convert to Record first.
|
||||||
let mut record = val.collect()?;
|
*self = val.collect()?;
|
||||||
record.update_data_at_cell_path(cell_path, new_val)?;
|
self.update_data_at_cell_path(cell_path, new_val)?;
|
||||||
*self = record;
|
|
||||||
}
|
}
|
||||||
Value::Error { error, .. } => return Err(*error.clone()),
|
Value::Error { error, .. } => return Err(*error.clone()),
|
||||||
v => {
|
v => {
|
||||||
@ -1409,10 +1407,8 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Value::LazyRecord { val, .. } => {
|
Value::LazyRecord { val, .. } => {
|
||||||
// convert to Record first.
|
// convert to Record first.
|
||||||
let mut record = val.collect()?;
|
*self = val.collect()?;
|
||||||
record.remove_data_at_cell_path(cell_path)?;
|
self.remove_data_at_cell_path(cell_path)
|
||||||
*self = record;
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
v => Err(ShellError::CantFindColumn {
|
v => Err(ShellError::CantFindColumn {
|
||||||
col_name: col_name.clone(),
|
col_name: col_name.clone(),
|
||||||
@ -1495,10 +1491,8 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Value::LazyRecord { val, .. } => {
|
Value::LazyRecord { val, .. } => {
|
||||||
// convert to Record first.
|
// convert to Record first.
|
||||||
let mut record = val.collect()?;
|
*self = val.collect()?;
|
||||||
record.remove_data_at_cell_path(cell_path)?;
|
self.remove_data_at_cell_path(cell_path)
|
||||||
*self = record;
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
v => Err(ShellError::CantFindColumn {
|
v => Err(ShellError::CantFindColumn {
|
||||||
col_name: col_name.clone(),
|
col_name: col_name.clone(),
|
||||||
@ -1624,9 +1618,8 @@ impl Value {
|
|||||||
}
|
}
|
||||||
Value::LazyRecord { val, .. } => {
|
Value::LazyRecord { val, .. } => {
|
||||||
// convert to Record first.
|
// convert to Record first.
|
||||||
let mut record = val.collect()?;
|
*self = val.collect()?;
|
||||||
record.insert_data_at_cell_path(cell_path, new_val, v_span)?;
|
self.insert_data_at_cell_path(cell_path, new_val, v_span)?;
|
||||||
*self = record;
|
|
||||||
}
|
}
|
||||||
other => {
|
other => {
|
||||||
return Err(ShellError::UnsupportedInput {
|
return Err(ShellError::UnsupportedInput {
|
||||||
|
Loading…
Reference in New Issue
Block a user