mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
remove --column
from length
command and remove record
processing (#10091)
# Description This PR removes `record` processing from the `length` command. It just doesn't make sense to try and get the length of a record. This PR also removes the `--column` parameter. If you want to list or count columns, you could use `$table | columns` or `$table | columns | length`. close #10074 ### Before  ### After Catches records two different ways now. with the `input_output_types` checker  and with additional logic in the command for cases like `echo`  # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass - `cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. -->
This commit is contained in:
@ -40,9 +40,10 @@ fn gets_first_row_when_no_amount_given() {
|
||||
Playground::setup("first_test_3", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), "ls | first | length");
|
||||
// FIXME: We should probably change first to return a one row table instead of a record here
|
||||
let actual = nu!(cwd: dirs.test(), "ls | first | values | length");
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
assert_eq!(actual.out, "4");
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,10 @@ fn gets_last_row_when_no_amount_given() {
|
||||
Playground::setup("last_test_2", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![EmptyFile("caballeros.txt"), EmptyFile("arepas.clu")]);
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), "ls | last | length");
|
||||
// FIXME: We should probably change last to return a one row table instead of a record here
|
||||
let actual = nu!(cwd: dirs.test(), "ls | last | values | length");
|
||||
|
||||
assert_eq!(actual.out, "1");
|
||||
assert_eq!(actual.out, "4");
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2,14 +2,21 @@ use nu_test_support::nu;
|
||||
|
||||
#[test]
|
||||
fn length_columns_in_cal_table() {
|
||||
let actual = nu!("cal | length -c");
|
||||
let actual = nu!("cal | columns | length");
|
||||
|
||||
assert_eq!(actual.out, "7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn length_columns_no_rows() {
|
||||
let actual = nu!("echo [] | length -c");
|
||||
let actual = nu!("echo [] | length");
|
||||
|
||||
assert_eq!(actual.out, "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn length_fails_on_echo_record() {
|
||||
let actual = nu!("echo {a:1 b:2} | length");
|
||||
|
||||
assert_eq!(actual.err.contains("only_supports_this_input_type"), true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user