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

wrapped sub-elements serialization bug fixed #70

Merged
merged 4 commits into from Jun 23, 2023
Merged

Conversation

dapper91
Copy link
Owner

@dapper91 dapper91 commented Jun 23, 2023

This MR fixes the bug related to wrapped sub-elements serialization.

The model:

from pydantic_xml import BaseXmlModel, element, wrapped

class Company(BaseXmlModel):
    title: str = element()
    country: str = wrapped('address', element())
    city: str = wrapped('address', element())

model = Company(title='SpaceX', country='US', city='Hawthorne')

should be serialized as the xml document:

<Company>
  <title>SpaceX</title>
  <address>
    <country>US</country>
    <city>Hawthorne</city>
  </address>
</Company>

but wrapped element is duplicated:

<Company>
  <title>SpaceX</title>
  <address>
    <country>US</country>
  </address>
  <address>
    <city>Hawthorne</city>
  </address>
</Company>

fixes the issue #63

@codecov-commenter
Copy link

codecov-commenter commented Jun 23, 2023

Codecov Report

Merging #70 (1fdff14) into dev (a6d40e6) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##              dev      #70      +/-   ##
==========================================
+ Coverage   93.11%   93.13%   +0.01%     
==========================================
  Files          23       23              
  Lines        1089     1092       +3     
==========================================
+ Hits         1014     1017       +3     
  Misses         75       75              
Flag Coverage Δ
unittests 93.13% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pydantic_xml/element/element.py 99.39% <100.00%> (+<0.01%) ⬆️
pydantic_xml/serializers/factories/union.py 87.95% <100.00%> (+0.14%) ⬆️

@dapper91 dapper91 merged commit 9616aee into dev Jun 23, 2023
6 checks passed
@dapper91 dapper91 mentioned this pull request Jun 23, 2023
Merged
@dapper91 dapper91 deleted the serialization-fix branch July 11, 2023 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants