Announcement

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

    Update with RestHandler does not use criteria

    Hi Isomorphic,

    please see this example in current 6.1p (11.1p_2018-04-11):
    employees.ds.xml addition:
    Code:
            <operationBinding operationType="update" operationId="updateSalary" allowMultiUpdate="true">
                <criteria fieldname="OrgUnit" operator="equals" value="TEST" />
            </operationBinding>
    ARC request to http://127.0.0.1:8888/builtinds/sc/RESTHandler:
    Code:
    <request>
        <dataSource>employees</dataSource>
        <operationType>update</operationType>
        <operationId>updateSalary</operationId>
            <data>
                <Salary>1000</Salary>
                 <criteria>
                     <Name>Ralph Brogan</Name>
                </criteria>
            </data>
    </request>
    Resulting SQL:
    Code:
    UPDATE employeeTable SET Salary=1000.0 WHERE (employeeTable.Salary=1000)
    I'd expect WHERE criteria for Name and OrgUnit.

    I have more issue here and will post them. This is an important one for me.

    Best regards
    Blama

    #2
    This request does generate criteria for Name. but not for OrgUnit:
    Code:
    <request>
        <dataSource>employees</dataSource>
        <operationType>update</operationType>
        <operationId>updateSalary</operationId>
            <data>
                <Salary>1000</Salary>
                <_constructor>AdvancedCriteria</_constructor>
                 <operator>and</operator>
                 <criteria>
                     <criterion>
                         <fieldName>Name</fieldName>
                         <operator>equals</operator>
                         <value>Ralph Brogan</value>
                     </criterion>
                </criteria>
            </data>
    </request>
    SQL:
    Code:
    UPDATE employeeTable SET Salary=1000.0 WHERE ((employeeTable.Name = 'Ralph Brogan' AND employeeTable.Name IS NOT NULL))
    Best regards
    Blama

    Comment


      #3
      On the first request, there should be no <criteria> tag under <data> - that's not the documented format. Just put <name> in directly.

      Comment


        #4
        Hi Isomorphic,

        thanks for the fast answer. How does the request then decide what is value and what is criteria, so what to put in the SET part of the SQL statement and what in the WHERE part?
        The operationBinding is allowMultiUpdate="true".

        Best regards
        Blama

        Comment


          #5
          The criteria is simply the primary key. There is not currently a format for a RestDataSource to send separate criteria for an allowMultiUpdate request, but this does not prevent such requests, as server logic can split the submitted data into criteria and values in whatever desired arrangement.

          Comment


            #6
            Hi Isomorphic,

            perhaps I need to mention that I'm not using clientside RestDataSource, but only serverside RESTHandler in order to create my API. It is consumed by 3rd party requests.
            So I'm more interested in the capabilities of the latter.

            It seems that the request from #2 is processed correctly, it just does not include the criteria defined on the operationBinding.

            Can you state what is currently supported here? Actually, I might be fine with the request format from #2 without the criteria defined on the operationBinding, if I stick to your advice here.
            The format from #2 seems to work although I'm not sure it is supported/will stay that way after reading your responses here in #5 and here.

            Best regards
            Blama

            Comment


              #7
              So again, <data> may not include criteria, it is simply a map of values, and the PK is required if the operation is not allowMultiUpdate:true. We're not sure why #2 would work at all - we would not expect it to per docs. So don't rely on it.

              Comment


                #8
                Hi Isomorphic,

                I removed the code and do all the work now in the DMI. This is working.

                It would be really good if the RESTHandler had the same capabilities IDACall has. Especially since it's not clear what is supported and what not.
                For example, the client RestDataSource docs mention <data> with embedded <criteria>. Here in the context of a FETCH, but it's mentioned nowhere that this does not work with UPDATE or other.

                Code:
                And an example of an XML message for a fetch operation passing AdvancedCriteria:
                     <request>
                         <data>
                             <_constructor>AdvancedCriteria</_constructor>
                             <operator>or</operator>
                             <criteria>
                                 <criterion>
                                     <fieldName>continent</fieldName>
                                     <operator>equals</operator>
                                     <value>North America</value>
                                 </criterion>
                                 <criterion>
                                     <operator>and</operator>
                                     <criteria>
                                         <criterion>
                                             <fieldName>continent</fieldName>
                                             <operator>equals</operator>
                                             <value>Europe</value>
                                         </criterion>
                                         <criterion>
                                             <fieldName>population</fieldName>
                                             <operator>greaterThan</operator>
                                             <value>50000000</value>
                                         </criterion>
                                     </criteria>
                                 </criterion>
                             </criteria>
                         </data>
                         <dataSource>countryDS</dataSource>
                         <operationType>fetch</operationType>
                         <startRow>0</startRow>
                         <endRow>75</endRow>
                         <componentId>worldGrid</componentId>
                     </request>
                I know that this is not an easy one, but perhaps something for your backlog.

                For completeness: I also had a similar problem here.

                Best regards
                Blama
                Last edited by Blama; 4 May 2018, 07:10. Reason: Replaced QUOTE by CODE

                Comment

                Working...
                X