Skip to content

Fix select on empty lists - #8651

Merged
rgwood merged 2 commits into
nushell:mainfrom
rgwood:fix-select-empty-list
Mar 28, 2023
Merged

rgwood merged 2 commits into
nushell:mainfrom
rgwood:fix-select-empty-list

Conversation

@rgwood

@rgwood rgwood commented Mar 28, 2023 •

Copy link
Copy Markdown
Contributor

This PR fixes select when given an empty list; it used to return null when given an empty list. I also cleaned up other select tests while I was in the area.

Before:

> [] | select a | to nuon
null

After:

> [] | select a | to nuon
[]

It looks like the previous behaviour was accidentally introduced by this PR.

@rgwood

rgwood commented Mar 28, 2023

Copy link
Copy Markdown
Contributor Author

I know it's getting close but I'd like to include this in the 0.78 release; I think it goes well with the other changes to cell paths.

@fdncred

fdncred commented Mar 28, 2023

Copy link
Copy Markdown
Contributor

We still have 7 days. I'd vote to land it too.

@rgwood

rgwood commented Mar 28, 2023

Copy link
Copy Markdown
Contributor Author

We still have 7 days.

Whoops, I lost track of time; thought it was less for some reason. Thanks!

@rgwood
rgwood merged commit da8cb14 into nushell:main Mar 28, 2023
@sholderbach

Copy link
Copy Markdown
Member

It looks like the previous behaviour was accidentally introduced by this PR.

So we can skip marking this as a breaking change?

Thanks should reduce type confusion!

@rgwood

rgwood commented Mar 28, 2023

Copy link
Copy Markdown
Contributor Author

Yeah, it could break scripts in theory but I doubt anyone was depending on this behaviour.

@rgwood

rgwood commented Mar 28, 2023

Copy link
Copy Markdown
Contributor Author

For context, this came up on Discord; a user was having trouble with web APIs that sometimes return an empty list.

WindSoilder pushed a commit to WindSoilder/nushell that referenced this pull request Mar 29, 2023
This PR fixes `select` when given an empty list; it used to return
`null` when given an empty list. I also cleaned up other `select` tests
while I was in the area.

### Before:

```
> [] | select a | to nuon
null
```

### After:

```
> [] | select a | to nuon
[]
```

It looks like the previous behaviour was accidentally introduced by
[this PR](nushell#7639).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants