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: properly handle deserialization from Reader #71

Merged

Conversation

vthib
Copy link
Contributor

@vthib vthib commented Sep 27, 2022

The pattern "let s: &str = Deserialize::deserialize(deser)" used in multiple places is not ideal, as it generates errors when the deserializer uses an IO Reader and not a string. To fix this, implementing a visitor is preferred, as it gives the deserializer the choice of allocating or not a string.

To ensure the issue is fixed, the tests now deserialize both from a string and from a reader.

I haven't used the same fix for the integer/string deserialization for numbers. Using a Visitor is much more cumbersome as it would depend on each numeric type, and using a Cow type is enough to fix the issue.

Closes #55

The pattern "let s: &str = Deserialize::deserialize(deser)" used
in multiple places is not ideal, as it generates errors when the
deserializer uses an IO Reader and not a string. To fix this,
implementing a visitor is preferred, as it gives the deserializer the
choice of allocating or not a string.

To ensure the issue is fixed, the tests now deserialize both from a
string and from a reader.

Closes influxdata#55
Copy link
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you, and sorry for the delay in reviewing.

Could you please sign the CLA and I can get this in 😄

@vthib
Copy link
Contributor Author

vthib commented Sep 30, 2022

Thanks, I have signed the CLA

@tustvold tustvold added the automerge Put in the merge queue label Oct 1, 2022
@kodiakhq kodiakhq bot merged commit 6f05959 into influxdata:main Oct 1, 2022
@tustvold
Copy link
Contributor

tustvold commented Oct 1, 2022

Thank you 😄

@vthib vthib deleted the 55-fix-deserialize-from-reader branch October 3, 2022 07:43
@tustvold tustvold mentioned this pull request Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Put in the merge queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parsing bytes from reader can lead to expected a borrowed string error
2 participants