-
Notifications
You must be signed in to change notification settings - Fork 252
Properly use xsi:nil to deserialize null values via serde #850
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
Conversation
This affects performance of the serde deserializer by ~20%, unfortunately
failures (11): as_field::empty::nested::true_ as_field::with_attr::nested::true_ as_field::with_element::nested::true_ as_field::with_element::ns0::true_ as_field::with_element::xsi::true_ top_level_option::empty::ns0::true_ top_level_option::empty::xsi::true_ top_level_option::with_attr::ns0::true_ top_level_option::with_attr::xsi::true_ top_level_option::with_element::ns0::true_ top_level_option::with_element::xsi::true_
This commit fixes an issue that causes `quick-xml` trying to deserialize empty tags via the serde interface even if these tags were explicitly marked as `xsi:nil="true"` For example the following XML failed to deserialize before this commit: ```xml <bar> <foo xsi:nil="true"/> </bar> ``` into the following rust type: ```rust #[derive(Deserialize)] struct Bar { foo: Option<Foo>, } #[derive(Deserialize)] struct Foo { baz: String, } ``` Before this commit this failed to deserialize with an error message that complained that the `baz` field was missing. After this commit this uses the `xsi:nil` attribute to deserialize this into `foo: None` instead. The standard (https://www.w3.org/TR/xmlschema-1/#xsi_nil) seems to support this behaviour. Fix tafia#497
406b2d0
to
3c4de88
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #850 +/- ##
==========================================
+ Coverage 60.21% 60.47% +0.26%
==========================================
Files 41 41
Lines 16021 16112 +91
==========================================
+ Hits 9647 9744 +97
+ Misses 6374 6368 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Supersedes #842 because I cannot push to it directly.
@weiznich, thanks for your contribution! I finally found the time to finish and polish your work. If you have anything to say about the proposed mapping scheme, feel free to.
Here is the benchmark results of
compare
subproject between master (c8fe850) and namespace-aware deserializer (b8ce862):criterion-namespace-aware-deserializer.zip