View Full Version : Model.replaceFields reads idProperty from wrong object

30 Jul 2015, 6:50 AM
If you call addFields/replaceFields from a model subclass (it's marked protected, not private) that has idProperty set to something different than its prototype, replaceFields crashes on this expression:

// The idField could have been replaced, so reacquire it.
me.idField = proto.idField = idField = fieldsMap[proto.idProperty];

It should NOT be reading idProperty from proto or modifying proto's idField, it should be:

// The idField could have been replaced, so reacquire it.
me.idField = idField = fieldsMap[me.idProperty];

Why should Ext.data.Model.idField be a reference to a field from a concrete model? Why read Ext.data.Model's default idProperty instead of the current class? When Ext.data.Model auto-generates the id field so that fieldsMap[idProperty] is assured to work, it uses the concrete classes' idProperty not the prototype's

This effects 5.x and 6.x

30 Jul 2015, 1:01 PM
Ext.data.NodeInterface#static-method-decorate does it too :(

idName = proto.idProperty;
idField = model.getField(idName);
idType = idField.type;

Gary Schlosberg
31 Jul 2015, 3:52 PM
Thanks for the report. Can you please create a test case which reproduces the behavior cause by this issue?

1 Aug 2015, 11:11 AM
Here you go: https://fiddle.sencha.com/#fiddle/rfv