Skip to content
New issue

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

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

Already on GitHub? # to your account

RUST-1933: Support deserializing $uuid extended JSON syntax #474

Merged
merged 2 commits into from
May 23, 2024

Conversation

mattChiaravalloti
Copy link
Contributor

@mattChiaravalloti mattChiaravalloti commented May 22, 2024

This PR updates the extended JSON deserializer to support the $uuid documented here. As noted in the ticket, this behavior now required for the Atlas SQL team. I confirmed locally that this change works for our purposes.

Looking through the code, it seems $uuid is supported in several other places but not for direct serde_json::from_str::<bson::Bson> parsing. I assume this was an accidental omission and not a deliberate choice.

I was unsure exactly where/how to test this. I spent a lot of time looking through the test files but I never quite figured out how/where/if you are testing this specific behavior (parsing extended json strings directly into Bson values), so I added a single, simple unit test to cover this. Let me know if testing should be done elsewhere or another way.

Edit: To be clear, our actual use case is using serde_yaml to parse yaml files that contain extended json values. The files are parsed into structs that have nested Bson fields, which is why this change is relevant and why we can't conveniently use the workaround of parsing into a serde_json::Value and then using TryFrom<serde_json::Value> for Bson. I updated the description to be a bit more lax to make this clear.

@kevinAlbs kevinAlbs requested a review from abr-egn May 22, 2024 19:07
@mattChiaravalloti mattChiaravalloti changed the title RUST-1933: Support $uuid extended JSON syntax in serde_json::from_str::<bson::Bson> RUST-1933: Support deserializing $uuid extended JSON syntax May 22, 2024
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

And yes, this was definitely an accidental omission. As you've noticed the internals of the library are a bit of a mess, we've got time scheduled this quarter to clean that up :)

@mattChiaravalloti
Copy link
Contributor Author

@abr-egn Thanks for the quick review! 2 questions:

  1. Does the lint failure matter for this PR? It's failing on master as well so I figure this is acceptable but lmk!
  2. Since I do not have write-access, would you mind merging this for me?

@abr-egn
Copy link
Contributor

abr-egn commented May 23, 2024

  1. Does the lint failure matter for this PR? It's failing on master as well so I figure this is acceptable but lmk!

Nope, this failure is unrelated to your PR. Thanks for checking though :)

  1. Since I do not have write-access, would you mind merging this for me?

Done!

@abr-egn abr-egn merged commit 343a7ce into mongodb:main May 23, 2024
9 of 11 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants