PDA

View Full Version : [CLOSED] Model fields not behaving sanely



mankz
5 Apr 2014, 10:17 AM
Ext.define('BaseModel', {
extend : 'Ext.data.Model'
});
Ext.define('BaseModel2', {
extend : 'BaseModel',

fields : [
'Usual2'
]
});


console.log(BaseModel2.fields)


Inspect the first field in the Array, it should be the 'id' field but this looks like some strange object and not like a Field at all.

evant
5 Apr 2014, 12:03 PM
We have a whole bunch of unit tests covering this, it looks ok to me:



Ext.require('*');


Ext.onReady(function() {

Ext.define('BaseModel', {
extend : 'Ext.data.Model'
});

Ext.define('BaseModel2', {
extend : 'BaseModel',

fields : [
'Usual2'
]
});

Ext.Array.forEach(BaseModel.fields, function(f) {
console.log(f.getName());
});

Ext.Array.forEach(BaseModel2.fields, function(f) {
console.log(f.getName());
});

});


There is some backwards compat stuff where it stuff the fields array into an items property on the array, because before you could ask for:



rec.fields.items // fields was a MixedCollection

mankz
5 Apr 2014, 2:56 PM
Hm, still not convinced. Look at the 'id' field, it's different in the two cases.

BaseModel2


Object
allowNull: true
critical: true
defaultValue: null
dependents: null
identifier: true
owner: function b(){return this.constructor.apply(this,arguments)||null}
__proto__: b


BaseModel


allowNull: true
cloneDefaultValue: false
critical: true
defaultValue: null
definedBy: function b(){return this.constructor.apply(this,arguments)||null}
identifier: true
name: "id"
ordinal: 0
persist: true
sortType: function (a){return a}
__proto__: Object


Is this according to spec?

evant
5 Apr 2014, 5:38 PM
What problem is this causing? Chrome probably isn't reporting the objects correctly because they get chain() called on them. But other than "they don't look right", is it causing any functional issues?

mankz
6 Apr 2014, 12:18 AM
No functional issues, just a bit surprised that a field mutates and is not identical after the Model is subclassed.