-
30 Aug 2012 8:35 AM #1
[ST 2.1.0-b2] two stores, same model: store items get overwritten (memory proxy)
[ST 2.1.0-b2] two stores, same model: store items get overwritten (memory proxy)
REQUIRED INFORMATION
Ext version tested:- Sencha Touch 2.1.0-beta3
- Sencha Touch 2.1.0-beta2
- Sencha Touch 2.0.1.1
- Sencha Touch 2.0.1 (works!)
- Chrome 21.0.1180.83 (Windows)
- two stores get created, based on the same model. items of the store which was created first, get partially overwritten
- The problem does NOT occur in ST 2.0.1
- Create a complex model (see example below)
- create two JSON-Strings
- create two stores (with storeId) which load the JSON-Strings via a memory proxy
- When app is running, click "Get data" to create Store No. 1
- Click "Show Data" and check the console output
- Click "Get Data 2" to create Store No. 2
- Click "Show Data" again and check the console output
- Two stores
- Store 1 contains data of string 1
- Store 2 contains data of string 2
- When store No. 2 is created, some content of store No. 1 is overwritten
- If there are for example 4 items in store No. 1 and there are 3 items in store No. 2, the fourth item in store No. 1 remains the same.
Code:Ext.define('simplestore027test.model.valueModel', { extend: 'Ext.data.Model', config: { idProperty : 'QUERY_NAME', hasOne : [ { model : 'simplestore027test.model.TXT_SYMBOLSModel', name : 'TXT_SYMBOLS', associationKey : 'TXT_SYMBOLS' } ] } }); Ext.define('simplestore027test.model.TXT_SYMBOLSModel', { extend : 'Ext.data.Model', config : { hasMany : [ { model : 'simplestore027test.model.RRWS_S_TEXT_SYMBOLSModel', name : 'RRWS_S_TEXT_SYMBOLS', associationKey : 'RRWS_S_TEXT_SYMBOLS' } ] } }); Ext.define('simplestore027test.model.RRWS_S_TEXT_SYMBOLSModel', { extend : 'Ext.data.Model', config : { idProperty : 'SYM_NAME', fields : [ 'SYM_NAME', 'SYM_VALUE' ] } }); Ext.define("simplestore027test.view.Main", { extend: "Ext.Container", requires: [ 'Ext.TitleBar', 'Ext.data.Store' ], alias: "widget.mainview", config: { layout: { fullscreen: true, type: 'fit' }, items: [{ xtype: "titlebar", title: "Web Service Test", docked: "top", items: [ { xtype: "button", text: 'Get Data', ui: 'action', itemId: "getDataButton" }, { xtype: "button", text: 'Get Data 2', ui: 'action', itemId: "getData2Button" }, { xtype: 'spacer' }, { xtype: "button", text: 'Show Data', ui: 'action', itemId: "showDataButton" } ] }, { html: [ '<h1>2.0.1</h1>', "<p>...</p>" ].join("") }], listeners: [{ delegate: "#getDataButton", event: "tap", fn: "onGetDataButtonTap", }, { delegate: "#getData2Button", event: "tap", fn: "onGetData2ButtonTap", }, { delegate: "#showDataButton", event: "tap", fn: "onShowDataButtonTap", } ] }, onGetDataButtonTap: function () { console.log("getDataCommand"); var jsonTestString = { "values": { "QUERY_NAME": "FirstQuery", "TXT_SYMBOLS": { "RRWS_S_TEXT_SYMBOLS": [ { "SYM_NAME": "AUTHOR", "SYM_VALUE": "DocBrown" }, { "SYM_NAME": "REPTNAME", "SYM_VALUE": "QRY01_CLIENT_COST_SALES" }, { "SYM_NAME": "REPTXTLG", "SYM_VALUE": "qry01_client_cost_sales" }, { "SYM_NAME": "USER", "SYM_VALUE": "Einstein" } ] } } } var store = Ext.create('Ext.data.Store', { model: 'simplestore027test.model.valueModel', data: jsonTestString, storeId: 'loadedQueriesStore' , proxy: { type : 'memory', reader: { type:'json', rootProperty:'values' } } }); }, onGetData2ButtonTap: function () { console.log("getData2Command"); var jsonTestString = { "values": { "QUERY_NAME": "SecondQuery", "TXT_SYMBOLS": { "RRWS_S_TEXT_SYMBOLS": [ { "SYM_NAME": "AUTHOR", "SYM_VALUE": "MartyMcFly" }, { "SYM_NAME": "REPTNAME", "SYM_VALUE": "QRY02_Whatever" }, { "SYM_NAME": "REPTXTLG", "SYM_VALUE": "qry02_whatever" } ] } } } var store = Ext.create('Ext.data.Store', { model: 'simplestore027test.model.valueModel', data: jsonTestString, storeId: 'helperQueriesStore', proxy: { type : 'memory', reader: { type:'json', rootProperty:'values' } } }); }, onShowDataButtonTap: function () { console.log("showDataCommand"); var loadedQueriesStore = Ext.getStore('loadedQueriesStore'); console.log("loadedQueriesStore"); console.log(loadedQueriesStore); var helperQueriesStore = Ext.getStore('helperQueriesStore'); console.log("helperQueriesStore"); console.log(helperQueriesStore); if (loadedQueriesStore){ console.log("---- loadedQueriesStore"); var qry01 = loadedQueriesStore.getAt(0); if (qry01) { console.log(qry01); var TXT_SYMBOLS = qry01.getTXT_SYMBOLSModel().RRWS_S_TEXT_SYMBOLS(); console.log('technical name: '); console.log(TXT_SYMBOLS.getById('REPTNAME').get('SYM_VALUE')); } } if (helperQueriesStore){ console.log("---- helperQueriesStore"); var qry01 = helperQueriesStore.getAt(0); if (qry01) { console.log(qry01); var TXT_SYMBOLS = qry01.getTXT_SYMBOLSModel().RRWS_S_TEXT_SYMBOLS(); console.log('technischer Name: '); console.log(TXT_SYMBOLS.getById('REPTNAME').get('SYM_VALUE')); } } } });
HELPFUL INFORMATION
Screenshot or Video:- attached
- Description of screenshot: Store No. 1 (loadedQueriesStore) after Creation of Store No. 2 (helperQueryStore)
- There should be DocBrown instead of MartyMcFly
See this URL for live test case: http:// Debugging already done:- none
- not provided
- only default css
- Windows 7 Pro 64
-
30 Aug 2012 8:48 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
Your test case isn't running for me. You don't need to have a controller and view and such... just console out things and run code.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
30 Aug 2012 8:58 AM #3
-
31 Aug 2012 1:10 AM #4
I changed the code above and tested it in ST 2.0.1, 2.0.1.1, 2.1.0-b2.
It only works in ST 2.0.1
-
31 Aug 2012 11:48 PM #5
-
4 Sep 2012 7:45 AM #6
Okay, again. Why is this still on INFOREQ?? Do you need any more information to reproduce this?
-
6 Sep 2012 7:18 AM #7
Okay, again. Why is this still on INFOREQ?? Do you need any more information to reproduce this?
-
12 Sep 2012 11:17 AM #8
Even tested it with ST2.1.0 beta3.
Could someone please have a look?
-
12 Sep 2012 11:23 AM #9Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,651
- Vote Rating
- 14
I'll get this over to the tracker.
-
13 Sep 2012 7:41 AM #10Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 4
Hi,
The issue is that the associated items have an idProperty of SYM_NAME. The data that your loading into the second store loads associations with the exact same SYM_NAME but different values for other fields. When you load items with the same model and id (which you are in this case), the existing records are updated. This is not a bug in the framework.
Let me know if this explanation helps you.
Best,
Tommy
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote
