Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix upsert index of zero #7350

Merged
merged 3 commits into from
Dec 6, 2022
Merged

fix upsert index of zero #7350

merged 3 commits into from
Dec 6, 2022

Conversation

Kangaxx-0
Copy link
Contributor

Description

Try to fix #7347, this pr does not fix the error message to upserting beyond 1 + the list's length doesn't work,, I feel this is still not explicit or general engouh, if we want to change, what would be the best message to be printed out ?

Add tests too

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 -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace to check that all tests pass

After Submitting

If your PR had any user-facing changes, update the documentation after the PR is merged, if necessary. This will help us keep the docs up to date.

@rgwood
Copy link
Contributor

rgwood commented Dec 5, 2022

Thanks for the PR!

Could we do this in a simpler way by just removing - 1 from this line?

return Err(ShellError::AccessBeyondEnd(idx - 1, *span));

I think that should actually be:

return Err(ShellError::AccessBeyondEnd(idx, *span)); 

It seems like N in the index too large (max: N) error message is always off by 1. For example:
image

That should say max: 1 not max: 0, because 1 works:
image

@Kangaxx-0
Copy link
Contributor Author

Thanks for the PR!

Could we do this in a simpler way by just removing - 1 from this line?

return Err(ShellError::AccessBeyondEnd(idx - 1, *span));

I think that should actually be:

return Err(ShellError::AccessBeyondEnd(idx, *span)); 

It seems like N in the index too large (max: N) error message is always off by 1. For example: image

That should say max: 1 not max: 0, because 1 works: image

Good catch! I've made the change

@rgwood
Copy link
Contributor

rgwood commented Dec 6, 2022

LGTM, thanks!

In the future, can you please include examples and/or screenshots in your PR descriptions? It will help the reviewers.

@rgwood rgwood merged commit 1af1e0b into nushell:main Dec 6, 2022
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.

[] | upsert 1 'foo' produces bad error
2 participants