Results 1 to 6 of 6

Thread: [0.7.10] date fields are not synchronized when updated

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Aug 2012
    Vote Rating

    Default [0.7.10] date fields are not synchronized when updated

    Versions: 0.7.10 (and 0.7.8) with Sencha Touch 2.1.1
    Browser: Chrome 24 (Win8 / Desktop)
    Severity: critical (data loss)
    Attachment: 0.7.10 patch proposal

    If updating a field handling a date object (for instance the date type field), this one is not synchronized when calling sync(). It's the case for all (custom) types which convert their raw value into Date (not only for the date field).

    Test case

    I modified the 'examples/touch/todo' example, replacing the timestamp 'int' type to 'date' (code detailed in this thread)

    - Create a new todo called 'A' and save it
    - Edit 'A', add a description and save. According the SIO log, data have been updated and sent to the remote server:
    DEBUG: Protocol.sendPutUpdate: {Object ...}
    DEBUG: Protocol.sync: end Object {r: "ok", sent: 2, status: "success"}
    - Edit 'A', show the 'save' button by doing and undoing a modification (e.g., change the 'complete' value to true, then false). Like that, only the timestamp field will change when saving the record. Save and check the SIO debug log:
    DEBUG: Protocol.sendPutUpdate: no work
    DEBUG: Protocol.sync: end Object {r: "ok", sent: 0}
    No data have been sent even if the timestamp has changed. Note that even if you update another field (e.g. the todo label), only the label field will be synchronized. The date field will be synchronized just once, at record creation.


    In SIO code, you are considering date as a complex value type. If setUpdateStateValue method arguments (cf/data/ModelWrapper.js) are dates, when checking if the value should be updated, you are trying to iterate over date objects (which are not iterables) and found no update because Ext.Array.intersect will return empty when intersecting 2 dates. To make it work, I changed calls to for a custom implementation, this._isIterable():
    PHP Code:
    _isIterable: function(value) {
            return (
    value !== null &&
    Ext.isDate(value) &&
    typeof value === 'object');

    setUpdateStateValue: function(tpathbefore_valueafter_value) {
            if (
    this._isIterable(after_value)) {
                if (
    before_value) {
    added= {};
                    if (
    this._isIterable(before_value)) {
    I attached the full patch over 0.7.10 used for my project (renamed in .txt, the forum doesn't accept .diff or .patch files).

    I know that SIO does not work well with date, and using date field is not recommended, but I hope this report will help you in this quest
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts