Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-3720 in a recent build.
  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    86
    Vote Rating
    4
    karazy is on a distinguished road

      0  

    Default ST 2.1 Store remove record fails with: Cannot call method 'hasOwnProperty' of null

    ST 2.1 Store remove record fails with: Cannot call method 'hasOwnProperty' of null


    Hi,

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

    Code:
    activeCheckIn.orders().remove(order);
    Code:
    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.

    Code:
       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

    Code:
        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.
    Code:
    if (modified.hasOwnProperty(fieldName)) {

    A Workaround for this problem is to set destroyRemovedRecords: false

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,622
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Thread Participants: 1