You found a bug! We've classified it as TOUCH-4076 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    1
    Vote Rating
    0
    customdev is on a distinguished road

      0  

    Default Ext.data.Model.cache returns data from the wrong store

    Ext.data.Model.cache returns data from the wrong store


    REQUIRED INFORMATION


    Ext version tested:
    • Sencha Touch 2.0.1.1
    Browser versions tested against:
    • WebKit for iOS 4
    • WebKit for iOS 5
    • WebKit for iOS 6
    • WebKit for Android 2.x
    • WebKit for Android 4.x
    DOCTYPE tested against:
    • html
    Description:
    • Ext.data.Model.cache returns data from the wrong store.
    Steps to reproduce the problem:
    • Create two stores based on the same model.
    • Add one entry to each store and use the same ID for each entry.
    • Do a getById() on the first store.
    The result that was expected:
    • You get the record from the first store.
    The result that occurs instead:
    • You get the record from the second store.
    Test Case:

    Code:
    Ext.define("ModelBugTest.model.KeyValuePair", {
        extend: "Ext.data.Model",
        config: {
            idProperty: "key",
            fields: [
                {name: "key", type: "string"},
                {name: "value", type: "string"}
            ]
        }
    });
    
    [...]
    
    Ext.define("ModelBugTest.store.KeyValuePairs1", {
            extend: "Ext.data.Store",
            requires: "Ext.data.proxy.LocalStorage",
            config: {
                model: "ModelBugTest.model.KeyValuePair",
                proxy: {
                    type: "localstorage",
                    id: "keyvaluepairs1"
                }
            }
        }
    );
    
    [...]
    
    Ext.define("ModelBugTest.store.KeyValuePairs2", {
            extend: "Ext.data.Store",
            requires: "Ext.data.proxy.LocalStorage",
            config: {
                model: "ModelBugTest.model.KeyValuePair",
                proxy: {
                    type: "localstorage",
                    id: "keyvaluepairs2"
                }
            }
        }
    );
    
    [...]
    
    Ext.application({
        name: "ModelBugTest",
    
        models: ["KeyValuePair"],
        stores: ["KeyValuePairs1", "KeyValuePairs2"],
    
        launch: function() {
        var record1 = Ext.create("ModelBugTest.model.KeyValuePair", {
            key: "key",
            value: "value1"
        });
        record1.setDirty();
        
        var store1 = Ext.getStore("KeyValuePairs1");
        store1.add(record1);
        store1.sync();
    
        var record2 = Ext.create("ModelBugTest.model.KeyValuePair", {
            key: "key",
            value: "value2"
        });
        record2.setDirty();
    
        var store2 = Ext.getStore("KeyValuePairs2");
        store2.add(record2);
        store2.sync();
    
        var record = store1.getById("key");
        if (record) {
            alert("" + record.get("value"));
        }
        }
    });


    HELPFUL INFORMATION


    Debugging already done:
    • Ext.data.Model.cache returns data from the wrong store in Ext.data.Model constructor method (lines 518-523 of src/data/Model.js).
    Possible fix:
    • Set useCache config property of Ext.data.Model to false in Sencha Touch 2.1.1.
    • No fix in Sencha Touch 2.0.1.1.
    Operating System:
    • OS X 10.8
    • Windows 7

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,624
    Vote Rating
    435
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Tags for this Thread