Skip to content
This repository

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

Merged
merged 1 commit into from almost 2 years ago

2 participants

C Anthony Risinger Burak Arslan
C Anthony Risinger
xtfxme commented June 12, 2012

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.

C Anthony Risinger [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
Burak Arslan
Owner
plq commented June 18, 2012

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

Burak Arslan
Owner
plq commented June 18, 2012

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

Burak Arslan plq merged commit 31fb18d into from June 18, 2012
Burak Arslan plq closed this June 18, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 12, 2012
C Anthony Risinger [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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  rpclib/protocol/xml/model.py
2  rpclib/protocol/xml/model.py
@@ -145,7 +145,7 @@ def get_members_etree(prot, cls, inst, parent):
145 145
                 prot.to_parent_element(v, sv, cls.get_namespace(), parent, k)
146 146
 
147 147
         # Don't include empty values for non-nillable optional attributes.
148  
-        elif subvalue is not None or (not v.Attributes.nillable or v.Attributes.min_occurs > 0):
  148
+        elif subvalue is not None or v.Attributes.min_occurs > 0:
149 149
             prot.to_parent_element(v, subvalue, cls.get_namespace(), parent, k)
150 150
 
151 151
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.