View Full Version : getUpdatedRecords() on association store doesn't seem to work properly

6 Jun 2013, 10:07 AM
This seems to be a bug, but figured I'd ask about it before posting it in the bug forum in case there's something I'm missing. Basically, I have a model with a hasMany association defined to another model. I then have a store for that model that I load up with data, including the associated data. All of that works fine. Where I have a problem is when I do something like this:

mainStore.getUpdatedRecords(); // Returns nothing
mainStore.getAt(0).myAssociation().getUpdatedRecords(); // Returns all associated records

So basically, all associated records always get returned by getUpdatedRecords() even though I have no updated any of them. Meanwhile, getUpdatedRecords() on the main store returns nothing, which I'm not sure I like, I'd think if any children have changed, you'd consider the parent to have changed as well since you're dealing with the entity as a whole. But I can live with that. I'm more concerned about all associated records being returned.

I could just call commitChanges() on each association store as soon as the main store is loaded, but seems like I shouldn't need to do that. Any idea?

6 Jun 2013, 10:47 AM
Actually figured it out. This thread got me on the right track: http://www.sencha.com/forum/showthread.php?239384

I looked into it some more and noticed that, like this thread, the problem had to do with the relationship keys. In my case, I had defined my hasMany association without specifying the primaryKey, assuming it would use the idProperty of my model. Apparently it doesn't (am guessing it's trying to use id instead). So I added primaryKey and now things behave as expected.