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

Parse nulls as None on nested serde structs #473

Merged
merged 1 commit into from Jun 20, 2022

Conversation

stusmall
Copy link
Contributor

@stusmall stusmall commented May 24, 2022

When parsing a structure nested inside an untagged enum serde treats
keys with a null value as Unit instead of calling visit_none. This
causes an error of "invalid type: null, expected an
RFC3339-formatted Option<OffsetDateTime>". This change just adds an
implementation for visit_unit so the value will be parsed as None as
expected.

@stusmall stusmall marked this pull request as draft May 24, 2022 22:54
@stusmall stusmall force-pushed the fix-parsing-of-nulls branch 2 times, most recently from 2bd853c to 5438d1b Compare May 24, 2022 23:22
@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #473 (7bb7748) into main (e893d31) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #473   +/-   ##
=======================================
  Coverage   99.48%   99.48%           
=======================================
  Files          70       70           
  Lines        7206     7209    +3     
=======================================
+ Hits         7169     7172    +3     
  Misses         37       37           
Impacted Files Coverage Δ
src/serde/visitor.rs 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e893d31...7bb7748. Read the comment docs.

@stusmall stusmall force-pushed the fix-parsing-of-nulls branch 2 times, most recently from 83f377d to bdd1da6 Compare May 25, 2022 16:12
@stusmall stusmall marked this pull request as ready for review May 25, 2022 16:18
@stusmall stusmall changed the title Parse nulls as None when using serde-well-known Parse nulls as None on nested serde structs May 25, 2022
@jhpratt jhpratt self-requested a review May 25, 2022 19:10
@jhpratt jhpratt added A-parsing Area: parsing C-enhancement Category: an enhancement with existing code A-well-known-format-description Area: well known format descriptions labels May 25, 2022
@github-actions
Copy link

This pull request has not had any activity recently. It will be closed without further activity.

@jhpratt jhpratt added C-keep-open Category: should not be closed due to inactivity and removed C-stale labels Jun 10, 2022
@jhpratt
Copy link
Member

jhpratt commented Jun 18, 2022

Would you mind rebasing? I think it's a matter of moving the new method into the newly-created macro.

@jhpratt jhpratt removed the C-keep-open Category: should not be closed due to inactivity label Jun 18, 2022
When parsing a structure nested inside an untagged enum serde treats
keys with a null value as Unit instead of calling visit_none.  This
causes an error of "invalid type: null, expected an
RFC3339-formatted `Option<OffsetDateTime>`".  This change just adds an
implementation for visit_unit so the value will be parsed as None as
expected.
@jhpratt jhpratt enabled auto-merge (squash) June 20, 2022 02:08
@jhpratt jhpratt merged commit b599d66 into time-rs:main Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parsing Area: parsing A-well-known-format-description Area: well known format descriptions C-enhancement Category: an enhancement with existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants