Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1612 in a recent build.
  1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    36
    Vote Rating
    0
    benben is on a distinguished road

      0  

    Default [PR4] Ext.data.writer.Json bug

    [PR4] Ext.data.writer.Json bug


    I was investigating why my model.save() sent garbage to my web service all of the sudden, and i found a bug in the "writeRecords" function :

    Code:
    ...
    if (this.getAllowSingle() && data && data.length == 1) {
                console.log("check convert to single object format");
                // convert to single object format
                data = data[0];
            }
    
    ...
    At that point "data" has been replaced by its first record.

    Then, a little later you do that:
    Code:
          if (!data || !data.length) {
                return request;
            }
    Which, obviously, returns a request with no "jsondata" set.

    So, my fix was to add this (pretty ugly) code (just to test) and it seems to work :
    Code:
     if (this.getAllowSingle() && data && data.length == 1) {
                console.log("check convert to single object format");
                // convert to single object format
                data = data[0];
    // HERE THAT PART WAS ADDED, BUT ITS JUST AN UGLY COPY/PASTE FIRST TRY
                jsonData = request.getJsonData() || {};
                if (root) {
                    jsonData[root] = data;
                } else {
                    jsonData = data;
                }
                request.setJsonData(jsonData);
    // END OF ADDED PART
            }
    Is there any other way of having correct json data in my POST request ?

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    10
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Thanks for the report. This is a bug and has been fixed for the next release. Is your workaround sufficient for now or do you need help with a temporary solution?

Thread Participants: 1

Tags for this Thread