Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Members with nillable=false and maxOccurs=0 still set nillable #142

Merged
merged 1 commit into from

2 participants

@xtfxme

Currently, when an element is optional, but NOT nillable, it's still set
nillable during serialization. However, when nillable=true, the member is
properly skipped. This behavior causes schema validation errors on the client.

Example schema:

    <xs:complexType name="object">
        <xs:sequence>
            [...]
            <xs:element name="id" type="xs:string" minOccurs="0" />
            <xs:element name="account" type="tns:account" minOccurs="0" />
            <xs:element name="last_updated" type="xs:dateTime" minOccurs="0" />
            [...]
        </xs:sequence>
    </xs:complexType>

Rpclib output:

    <tns:object>
        [...]
        <tns:id>4fd7ad136b6b473006000005</tns:id>
        <tns:account xsi:nil="true"/>
        <tns:last_updated xsi:nil="true"/>
        [...]
    </tns:object>

... correct by not caring if nillable when deciding to skip or not.

@xtfxme xtfxme [issue #142] Members with nillable=false and maxOccurs=0 still set ni…
…llable

Currently, when an element is optional, but NOT nillable, it's still set
nillable during serialization. However, when nillable=true, the member is
properly skipped. This behavior causes schema validation errors on the client.

Example schema:
    <xs:complexType name="object">
        <xs:sequence>
            [...]
            <xs:element name="id" type="xs:string" minOccurs="0" />
            <xs:element name="account" type="tns:account" minOccurs="0" />
            <xs:element name="last_updated" type="xs:dateTime" minOccurs="0" />
            [...]
        </xs:sequence>
    </xs:complexType>

Rpclib output:
    <tns:object>
        [...]
        <tns:id>4fd7ad136b6b473006000005</tns:id>
        <tns:account xsi:nil="true"/>
        <tns:last_updated xsi:nil="true"/>
        [...]
    </tns:object>

... correct by not caring if nillable when deciding to skip or not.
3340b7b
@plq
Owner

this is a subtle change. would you mind adding tests as well?

@plq
Owner

nah, that would be too much of a hassle. your patch makes perfect sense anyway.

@plq plq merged commit 31fb18d into arskom:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 12, 2012
  1. @xtfxme

    [issue #142] Members with nillable=false and maxOccurs=0 still set ni…

    xtfxme authored
    …llable
    
    Currently, when an element is optional, but NOT nillable, it's still set
    nillable during serialization. However, when nillable=true, the member is
    properly skipped. This behavior causes schema validation errors on the client.
    
    Example schema:
        <xs:complexType name="object">
            <xs:sequence>
                [...]
                <xs:element name="id" type="xs:string" minOccurs="0" />
                <xs:element name="account" type="tns:account" minOccurs="0" />
                <xs:element name="last_updated" type="xs:dateTime" minOccurs="0" />
                [...]
            </xs:sequence>
        </xs:complexType>
    
    Rpclib output:
        <tns:object>
            [...]
            <tns:id>4fd7ad136b6b473006000005</tns:id>
            <tns:account xsi:nil="true"/>
            <tns:last_updated xsi:nil="true"/>
            [...]
        </tns:object>
    
    ... correct by not caring if nillable when deciding to skip or not.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  rpclib/protocol/xml/model.py
View
2  rpclib/protocol/xml/model.py
@@ -145,7 +145,7 @@ def get_members_etree(prot, cls, inst, parent):
prot.to_parent_element(v, sv, cls.get_namespace(), parent, k)
# Don't include empty values for non-nillable optional attributes.
- elif subvalue is not None or (not v.Attributes.nillable or v.Attributes.min_occurs > 0):
+ elif subvalue is not None or v.Attributes.min_occurs > 0:
prot.to_parent_element(v, subvalue, cls.get_namespace(), parent, k)
Something went wrong with that request. Please try again.