-
1 Mar 2013 10:06 AM #1
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
- WebKit for iOS 4
- WebKit for iOS 5
- WebKit for iOS 6
- WebKit for Android 2.x
- WebKit for Android 4.x
- html
- Ext.data.Model.cache returns data from the wrong store.
- 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.
- You get the record from the first store.
- You get the record from the second store.
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).
- 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.
- OS X 10.8
- Windows 7
-
1 Mar 2013 10:42 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
Thanks for the report! I have opened a bug in our bug tracker.
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.


Reply With Quote