mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 03:44:19 +01:00
Take all rows having the column present.
This commit is contained in:
parent
1c830b5c95
commit
06857fbc52
@ -37,7 +37,7 @@ pub fn compact(
|
|||||||
CompactArgs { rest: columns }: CompactArgs,
|
CompactArgs { rest: columns }: CompactArgs,
|
||||||
RunnableContext { input, .. }: RunnableContext,
|
RunnableContext { input, .. }: RunnableContext,
|
||||||
) -> Result<OutputStream, ShellError> {
|
) -> Result<OutputStream, ShellError> {
|
||||||
let objects = input.values.take_while(move |item| {
|
let objects = input.values.filter(move |item| {
|
||||||
let keep = if columns.is_empty() {
|
let keep = if columns.is_empty() {
|
||||||
item.is_some()
|
item.is_some()
|
||||||
} else {
|
} else {
|
||||||
|
@ -59,7 +59,7 @@ fn default(
|
|||||||
if should_add {
|
if should_add {
|
||||||
match item.insert_data_at_path(&column.item, value.item.clone()) {
|
match item.insert_data_at_path(&column.item, value.item.clone()) {
|
||||||
Some(new_value) => result.push_back(ReturnSuccess::value(new_value)),
|
Some(new_value) => result.push_back(ReturnSuccess::value(new_value)),
|
||||||
None => {}
|
None => result.push_back(ReturnSuccess::value(item)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.push_back(ReturnSuccess::value(item));
|
result.push_back(ReturnSuccess::value(item));
|
||||||
|
@ -4,7 +4,7 @@ use helpers as h;
|
|||||||
use helpers::{Playground, Stub::*};
|
use helpers::{Playground, Stub::*};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn default() {
|
fn default_row_data_if_column_missing() {
|
||||||
Playground::setup("default_test_1", |dirs, sandbox| {
|
Playground::setup("default_test_1", |dirs, sandbox| {
|
||||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
"los_tres_amigos.json",
|
"los_tres_amigos.json",
|
||||||
|
Loading…
Reference in New Issue
Block a user