Announcement

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

    6.1p clientOnly DataSource update works although it should not (missing primaryKey)

    Hi Isomorphic,

    I wanted to create a testcase for this one and thought I might be fast in JS - I was not.
    Nevertheless I stumbled upon two problems doing so which I believe might be a bug:

    Please see this modified sample (v11.1p_2018-04-20):
    Code:
    isc.DataSource.create({
        ID:"contacts",
        dataFormat:"json",
        dataURL:"[ISOMORPHIC]/system/reference/inlineExamples/dataIntegration/json/contactsData.js",
        fields:[
            {name:"name", primaryKey: true, required:true},
            {name:"email"},
            {name:"organization"},
            {name:"phone"},
            {name:"street", valueXPath:"address/street" },
            {name:"city", valueXPath:"address/city" },
            {name:"state", valueXPath:"address/state"},
            {name:"zip", valueXPath:"address/zip" }
        ],
        operationBindings : [
            { operationType:"update", operationId:"updateMultiple", allowMultiUpdate: false }
        ]
    });
    
    isc.ListGrid.create({
        ID: "boundGrid",
        dataSource: "contacts",
        height: "100%",
        width: "100%",
        autoFetchData: true
    });
    
    isc.DynamicForm.create({
        ID: "boundForm",
        autoFetchData: true,
        width: 250,
        dataSource: "contacts",
        fields:[
            {name:"email"},
            {name:"organization"},
        ]
    });
    
    isc.IButton.create({
        ID:"updateButton",
        title:"Update Record",
        click : function () {
            var record = boundForm.getValues();
            delete record['name'];
            delete record['email'];
            delete record['organization'];
            delete record['phone'];
            contacts.updateData(record, null, { operationId:"updateMultiple" });
        }
    });
    
    isc.VLayout.create({
        ID:"layout",
        height: "100%",
        width: "100%",
        members: [boundGrid, boundForm, updateButton]
    });
    1) If you click the button it will issue an update<updateMultiple> request without PK. allowMultiUpdate: false is explicitly false in the DataSource declaration, so why does the request end in status SUCCESS anyway?

    2) If you comment out the delete record['name']; why does the Response in the RPC Tab includeall three records of the DataSource? (It does also with that line, but if it is commented out, we definitely have a primaryKey in the UPDATE, so why does the response include all records?)


    Thank you & Best regards
    Blama

    #2
    clientOnly DataSources do not currently support allowMultiUpdate.

    Comment


      #3
      Hi Isomorphic,

      OK, thanks. I did not know this. Is this somewhere in the docs? These two don't mention it.

      This does not explain the result, tough. The operationBinding has allowMultiUpdate:false, the default. So an update without PK should fail, shouldn't it?
      Also, with and without PK, why are three records in the response?

      Best regards
      Blama

      Comment


        #4
        allowMultiUpdate is not documented as a property that is valid on client-side DataSources. It appears only in the reference for server DataSources.

        At the moment, a clientOnly DataSource does not enforce the security constraints which are documented for server DataSources, and simply does not the wrong thing if the request if an update request is invalid in this way.

        Comment


          #5
          Hi Isomorphic,

          thanks, I saw it now - it's not in the docs of clientside smartgwt.*, only in the .ds.xml docs.
          I nevertheless think there is an issue (v11.1p_2018-05-24) - because I explicitly set allowMultiUpdate: false, which is the default anyway.

          See the sample response or the response for this testcase (without allowMultiUpdate), if you change something in the form (e.g. the email-field).
          IMHO this is no correct - the response does include 3 records instead of 1 and also the data (email) is not updated at all.
          Code:
          isc.DataSource.create({
              ID:"contacts",
              dataFormat:"json",
              dataURL:"[ISOMORPHIC]/system/reference/inlineExamples/dataIntegration/json/contactsData.js",
              fields:[
                  {name:"name", primaryKey: true, required:true},
                  {name:"email"},
                  {name:"organization"},
                  {name:"phone"},
                  {name:"street", valueXPath:"address/street" },
                  {name:"city", valueXPath:"address/city" },
                  {name:"state", valueXPath:"address/state"},
                  {name:"zip", valueXPath:"address/zip" }
              ]
          });
          
          isc.ListGrid.create({
              ID: "boundGrid",
              dataSource: "contacts",
              height: "100%",
              width: "100%",
              autoFetchData: true
          });
          
          isc.DynamicForm.create({
              ID: "boundForm",
              autoFetchData: true,
              width: 250,
              dataSource: "contacts",
              fields:[
                  {name:"name", canEdit: false},
                  {name:"email"},
                  {name:"organization"},
              ]
          });
          
          isc.IButton.create({
              ID:"updateButton",
              title:"Update Record",
              click : function () {
                  var record = boundForm.getValues();
                  contacts.updateData(record);
              }
          });
          
          isc.VLayout.create({
              ID:"layout",
              height: "100%",
              width: "100%",
              members: [boundGrid, boundForm, updateButton]
          });
          Click image for larger version

Name:	clientOnly Update.png
Views:	110
Size:	86.8 KB
ID:	253356

          Best regards
          Blama

          Comment


            #6
            So again, clientOnly DataSources do not support multi-record update. Any attempted update that would target multiple records will not work.

            Comment


              #7
              Hi Isomorphic,

              I got that. But the "name"-field is primaryKey (see the modified sample) and included in the data - so this should target only a single row.

              Also a updateButton-ClickHandler of
              Code:
                  click : function () {
                      boundForm.saveData();
                  }
              does not change anything - three rows in the response, no row changed.

              Best regards
              Blama

              Comment


                #8
                The problem is that this isn't actually a clientOnly DataSource - you haven't set clientOnly. The DataSource is trying to contact the dataURL to perform an update, and the dataURL is just a static file that returns the original 3 records, unchanged.

                Comment


                  #9
                  Hi Isomorphic,

                  OK, got it. Now that you say it: There was no "clientOnly" in the Developer Console RPC Tab, which is there normally for clientOnly-DS. Sorry for the bogus report.

                  Best regards
                  Blama

                  Comment

                  Working...
                  X