PDA

View Full Version : [FIXED] [ST2 PR2] store proxy load and sync bug



Di Peng
1 Dec 2011, 5:07 PM
Hi, following pseudocode illustrates the problem/bug I am having:
I have a store called 'myStore'

myStore.load() => loads 2 records from backend through a read operation.
myStore.sync() => I would expect nothing happens as I did not do anything with the store data. However, both records I just loaded got sent back to the backend as a create operation.

Following code snippet will reproduce the bug:



Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'}
]});

var myStore = Ext.create('Ext.data.Store', {
model: 'User',
proxy: {
type: 'ajax',
api: {
create : 'backend/create.php',
read : 'backend/read.php',
update : 'backend/update.php',
destroy : 'backend/destroy.php'
},
reader: {
type: 'json',
root: 'users'
}
}
});
//Keep network inspector open when executing the following lines
myStore.load() // goes to 'backend/read.php'
myStore.sync() // same records that just got loaded goes to 'backend/create.php'

This bug was produced on the latest stable Chrome
Thanks
Di

mitchellsimoens
2 Dec 2011, 9:46 AM
I personally don't get the create operation but I get another error while trying to update.

Thank you for the report.

TommyMaintz
5 Jan 2012, 7:28 AM
Loading a store and instantly synchronizing works as expected in the next release of Touch 2.0.

In your case however, I think the issue is something else. For a record to be seen as a "phantom" record on the client side it has to be created without an id. Were you sending back id's back from the server side for each record? If not, they are phantom and will be send back in a create operation to the server the next time you sync.