Skip to content

Fix select on empty lists#8651

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

Fix select on empty lists#8651
rgwood merged 2 commits intonushell:mainfrom
rgwood:fix-select-empty-list

Conversation

@rgwood
Copy link
Copy Markdown
Contributor

@rgwood rgwood commented Mar 28, 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.

@rgwood
Copy link
Copy Markdown
Contributor Author

rgwood commented Mar 28, 2023

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
Copy link
Copy Markdown
Contributor

fdncred commented Mar 28, 2023

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

@rgwood
Copy link
Copy Markdown
Contributor Author

rgwood commented Mar 28, 2023

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
Copy link
Copy Markdown
Contributor Author

rgwood commented Mar 28, 2023

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

@rgwood
Copy link
Copy Markdown
Contributor Author

rgwood commented Mar 28, 2023

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