Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    6.1p RESTHandler problem with sending boolean values for ADD

    Hi Isomorphic,

    RESTHandler in current nightly (v11.1p_2017-12-05) has a problem with boolean values. I used ARC to send a request to http://127.0.0.1:8888/builtinds/sc/RESTHandler
    I'm using this .ds.xml, but the original one should be good as well to show the problem:

    supplyItem.ds.xml change:
    Code:
    <field name="inStock"   type="boolean"  length="1" title="In Stock" escapeHTML="true" sqlStorageStrategy="singleCharYN" />
    Request Body, Both OK (see true/false):
    Code:
    <request>
        <dataSource>supplyItem</dataSource>
        <operationType>add</operationType>
        <data>
            <itemName>Agent pen</itemName>
            <SKU>007</SKU>
            <category>Office Paper Products</category>
            <unitCost>0.07</unitCost>
            <units>Ea</units>
            <inStock>true</inStock>
        </data>
    </request>
    
    <request>
        <dataSource>supplyItem</dataSource>
        <operationType>add</operationType>
        <data>
            <itemName>Agent pen</itemName>
            <SKU>007</SKU>
            <category>Office Paper Products</category>
            <unitCost>0.07</unitCost>
            <units>Ea</units>
            <inStock>false</inStock>
        </data>
    </request>
    Request Body, Not OK (results in 'N' in INSERT statement):
    Code:
    <request>
        <dataSource>supplyItem</dataSource>
        <operationType>add</operationType>
        <data>
            <itemName>Agent pen</itemName>
            <SKU>007</SKU>
            <category>Office Paper Products</category>
            <unitCost>0.07</unitCost>
            <units>Ea</units>
            <inStock>foobar</inStock>
        </data>
    </request>
    Request Body, Not OK (results in 'N' in INSERT statement):
    Code:
    <request>
        <dataSource>supplyItem</dataSource>
        <operationType>add</operationType>
        <data>
            <itemName>Agent pen</itemName>
            <SKU>007</SKU>
            <category>Office Paper Products</category>
            <unitCost>0.07</unitCost>
            <units>Ea</units>
        </data>
    </request>
    In my application the problem is slightly different, which is the reason I noticed the issue in the 1st place:
    true is working as expected, everything else is ignored (here everything else is made false (= 'N'))

    This is an important one for me, as I need to be able to send false in my user-requests. The problem is not exact as in my application, but one can see that this is definitely not doing whats is intended.
    I'd expect the framework to use null as column value for <inStock></inStock> and to complain with a validation error for every value that's not empty or true or false.

    Best regards
    Blama

    #2
    Hi Isomorphic,

    for the null problem, please see these requests:

    Request body:
    Code:
    <request>
        <dataSource>supplyItem</dataSource>
        <operationType>update</operationType>
        <data>
           <itemID>3964</itemID>
           <itemName>Agent pen2</itemName>
            <inStock></inStock>
        </data>
    </request>
    
    <request>
        <dataSource>supplyItem</dataSource>
        <operationType>update</operationType>
        <data>
           <itemID>3964</itemID>
           <itemName>Agent pen2</itemName>
            <inStock>null</inStock>
        </data>
    </request>
    Both do not set the column to null, but to false. This is not important for me right now, but should also be solved. Also, setting a null-value should be part of the samples in the RestDataSource-docs, IMHO.
    Sending dates, the other special case, is covered here.

    Best regards
    Blama

    Comment


      #3
      We've made a change to allow you to specify "null" as in your second request and have it map to null. This has been applied to SGWT 6.1p/SC 11.1p and newer releases and will be in the nightly builds dated 2017-12-12.

      Alternatively, you may also modify the supplyItem.ds.xml definition to add this xmlns:xsi attribute:
      Code:
      <DataSource xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
          ID="supplyItem"
          :
      and then send your request as

      Code:
      <request>
          <dataSource>supplyItem</dataSource>
          <operationType>update</operationType>
          <data>
             <itemID>3964</itemID>
             <itemName>Agent pen2</itemName>
             <inStock xsi:nil="true"/>
          </data>
      </request>

      Comment


        #4
        Hi Isomorphic,

        I can see that null,false and true now work as expected (v11.1p_2017-12-27).
        Additionally, all other values including empty string are converted to true as well. This is minor IMHO, but I think this should result in some kind of error.

        This is exactly the same behavior as in this thread.

        Best regards
        Blama

        Comment

        Working...
        X