-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
preserve space by letting to nuon
only add quotes when necessary
#6379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the intention. But I am not sure how we want to develop the .nuon
format. If it should follow JSON as a superset or try to be as close to regular handwritten nu code.
If we want to be as close to an extended JSON, string keys would have to be escaped as explicit strings anyways.
I'd vote for the "close to the handwritten Nushell" option. The important part is that any JSON is a valid NUON, but the other way is not so important. NUON already supports a lot of things that are not close to JSON at all, like the table syntax. We can make an advantage of this to make NUON more user-friendly and space-efficient. Maybe @fdncred has an opinion as well? |
My goal for pushing for this PR was to make nuon as small as possible, so removing extraneous quotes helps that. The reason why I want it to be small is because I think that was one of the founding principles for nuon. I remember JT comparing size against many other serialization formats and nuon was pretty much beating them all. So, I'd vote for nuon to be as close to handwritten nushell as possible. I'd also like nuon to support all our syntax including things like blocks so we can serialize/deserialize 100% of nu-lang. |
Looking at the list of the blacklisted characters, this PR would really use some proper smoke test. Like testing all sorts of weird strings as column names and making sure we can |
Maybe fuzzing with |
Yeah, we need fuzzing but that's out of scope of this PR. Fuzzing probably should be in a separate place and in a separate CI step to keep the rest of the Nushell tests deterministic. It would be quite annoying if you had a random fuzzing failure on your PR that has nothing to do with your changes. Here, I would just think of all sorts of weird cursed strings and make sure we can do the roundtrip. |
True, we shouldn't fuzz on the PR workflow. But it seems that the proptest crate supports some features to persist previous failure cases https://docs.rs/proptest/0.7.2/proptest/#failure-persistence (Don't know if one can run those examples without executing proptest or if we have to manually extract unit tests from the failure log) |
ok, it seems like we have consensus that this PR is fine and we need to use |
I'd still put more tests to make sure names with all weird characters are quoted correctly (or disallowed as column names, either way). I think currently missing are newlines, tabs or pipes. There might be more. |
oops, sorry. i thought we were ready. @merelymyself can you add a few more tests like kubouch suggests please? |
…ushell#6379) * preserve space by letting `to nuon` only add quotes when necessary * fix CI, add quotes with colon * fmt * add more chars to blacklist
Description
Related: #6376 (comments), #6283
Quotes are now only used when absolutely needed, i.e. there is a space or comma in the name.
Tests
Make sure you've done the following:
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 --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect
to check that you're using the standard code stylecargo test --workspace --features=extra
to check that all the tests pass