-
25 Jan 2012 3:57 PM #1
[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 :
At that point "data" has been replaced by its first record.Code:... if (this.getAllowSingle() && data && data.length == 1) { console.log("check convert to single object format"); // convert to single object format data = data[0]; } ...
Then, a little later you do that:
Which, obviously, returns a request with no "jsondata" set.Code:if (!data || !data.length) { return request; }
So, my fix was to add this (pretty ugly) code (just to test) and it seems to work :
Is there any other way of having correct json data in my POST request ?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 }
-
25 Jan 2012 4:22 PM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
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?
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1612
in
2.0.


Reply With Quote
