PDA

View Full Version : model.save() phantom problem when success:false



dedoz
14 Mar 2012, 1:58 AM
im using 4.1 beta 3 with a model using direct proxy and everything works fine, i can save to the database and get right success responses from server, but the record will go phatom : false even when success is false.


p = Ext.create('Person',{name:'robinson'});
console.log(p.phantom); // true
p.save({
callback : function(record,operation)
{ if (!operation.response.success)
console.log('ERROR : ' + operation.response.message);
else
console.log('sucess');

console.log(p.phantom); // false
console.log(record.phantom); //false
}
});

my json response is


{ "type":"rpc",
"tid":1,
"action":"testQuery",
"method":"Insert",
"result":
{"id":null,"name":"robinson"},
"success":false,
"message":"unique,name"
}

detects the success : false in the if(!operation.response.sucess) and prints the correct menssage to the console log.
thats working fine.
problem is , even when sucess is false, record changed to phantom:false (means it was saved to the server) i know i can set it manually to true again but i think shouldnt be happening and i dont know the consecuences of setting panthom back to true manually. also prolly is happening in store.sync() (havent tested) and there is goin to be harder to detect the record that needs to be set to phantom true again.

so im doing something wrong or its another phantom problem (note another :d)

question #2
if i put console.log(operation.wasSuccessful()) inside the callback, prints true ??
but console.log(operation.response.sucess) prints false which is the correct answer. maybe thats the source of the panthom problem ? operation.sucess is true and only operation.response.sucess is false. maybe im mising something ?

EDIT
its worst than that, the whole record assumes the new values even when sucess is false, so
doing a reject wont give me the old values back D:


// if i add this to the callback
console.log(record); // values that shouldnt be assumed
record.reject();
console.log(record); // same values, cannot reject to get the old values


anyone ? D:

dang i need to finish an app like 3 month ago D: my boss wants to kill me and i keep finding bugs this is like the #11 in data package i posted like 3 cuz consumes too much time to isolate the test cases and redact the bug and then i wont get any fix soon so after i found one bug i just override with a fix and keep goin D: but its sad ill be looking for a new job soon i guess D:

mitchellsimoens
14 Mar 2012, 10:21 AM
What Ext JS 4 version are you using? Sounding more like a bug

dedoz
14 Mar 2012, 11:59 AM
What Ext JS 4 version are you using? Sounding more like a bug
4.1 beta 3

mitchell theres another phantom realated problem (4.1 beta3 also), i didnt had time to post. its more a "problem" than a bug, it just presents inconsistent info.


p = Ext.create('Person',{id:4 , name: 'peter'})
p.save() // triggers an update where should be create because i just created that record.

problem comes from phantom, Ext.create when an id is given starts as phantom:false then model.save() its fooled and thinks the records existis in the database because of phantom.
this wont let save records for database tables where the id is not "auto incremental" or "sql server indentity".
but this is another bug not realted to my orignal post.