PDA

View Full Version : [FIXED] ST 2.1 Store remove record fails with: Cannot call method 'hasOwnProperty' of null



karazy
16 Nov 2012, 4:10 AM
Hi,

I'm trying to remove a record from a store of a hasMany association.



activeCheckIn.orders().remove(order);




associations: [{
type: 'hasMany',
model: 'MyApp.model.Order',
name: 'orders',
store: {
syncRemovedRecords: false
}
}]


This operation fails with a Cannot call method 'hasOwnProperty' of null in model.js Line 798.
Debugging revealed that during removing of the record in model.js destroy function modified is set to null.



destroy: function() {
var me = this;
me.notifyStores('afterErase', me);
if (me.getUseCache()) {
delete Ext.data.Model.cache[Ext.data.Model.generateCacheId(me)];
}
me.raw = me.stores = me.modified = null;
me.callParent(arguments);
},


Later in hasMany.js onRemoveRecords the foreign key is set to null



onRemoveRecords: function(store, records) {
var ln = records.length,
i, record;
for (i = 0; i < ln; i++) {
record = records[i];
record.set(this.getForeignKey(), null);
}
},


This fails in the Model.js set method in Line 798 because obviously modified is null.


if (modified.hasOwnProperty(fieldName)) {



A Workaround for this problem is to set destroyRemovedRecords: false

mitchellsimoens
16 Nov 2012, 10:19 AM
Thanks for the report! I have opened a bug in our bug tracker.