Success! Looks like we've fixed this one. According to our records the fix was applied for a bug in our system in a recent build.
  1. #1
    Ext Premium Member
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    196
    Vote Rating
    3
    bone is on a distinguished road

      0  

    Default Ext.data.writer.Writer - data[record.idProperty]

    Ext.data.writer.Writer - data[record.idProperty]


    4.0.1 and 4.0.2

    The documentation for idProperty clearly states that "The name of the field treated as this Model's unique id (defaults to 'id').".

    Code:
    getRecordData: function(record){
      ....
      if(!isPhantom){
        // always include the id for non phantoms
        data[record.idProperty] = record.getId();
      }
    }
    This basically ignores any mapping defined in the field.

    I did this quick'n'dirty fix to make it work in the writer we already had to create because attribute-mapping fails (<@id>blah</@id>):
    Code:
         data[fields.get(record.idProperty).mapping || record.idProperty] = record.getId();
    Founder of the Path of Exticism

  2. #2
    Ext Premium Member
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    196
    Vote Rating
    3
    bone is on a distinguished road

      0  

    Default


    bumping for confirmation
    Founder of the Path of Exticism

  3. #3
    Ext JS Premium Member
    Join Date
    May 2009
    Posts
    55
    Vote Rating
    0
    bodyboarder20 is on a distinguished road

      0  

    Default


    Im running into this same exact problem.

    ColdFusion loves to spit out UPPERCASE fields, so I have to re-map everything as such

    Code:
    ...
    idProperty: 'ID',
    
    fields: [
            {name: 'id',        type: 'int',    mapping: 'ID'},
    ...
    This does work in the sense that the ID is properly set on the record and phantom is set to false, (so I could theoretically call record.id), but calls to record.getId() fail because its looking for a field named ID in my model - that doesnt exist.....

    Maybe a workaround could be to reset the idProperty of the model to the mapped fieldafter the model has been loaded?

  4. #4
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Norway
    Posts
    24
    Vote Rating
    0
    atomcat is on a distinguished road

      0  

    Default


    Hi,

    The suggested fix is a bit buggy, because if nameProperty is not set to 'mapping', even than it uses the mapping for the id property.

    So, I'd suggest this bugfix:

    Code:
    Ext.override(Ext.data.writer.Writer, {        
    getRecordData: function(record) {
                var isPhantom = record.phantom === true,
                    writeAll = this.writeAllFields || isPhantom,
                    nameProperty = this.nameProperty,
                    fields = record.fields,
                    data = {},
                    changes,
                    name,
                    field,
                    key;
    
    
                if (writeAll) {
                    fields.each(function(field){
                        if (field.persist) {
                            name = field[nameProperty] || field.name;
                            data[name] = record.get(field.name);
                        }
                    });
                } else {
                    // Only write the changes
                    changes = record.getChanges();
                    for (key in changes) {
                        if (changes.hasOwnProperty(key)) {
                            field = fields.get(key);
                            name = field[nameProperty] || field.name;
                            data[name] = changes[key];
                        }
                    }
                    if (!isPhantom) {
                        // always include the id for non phantoms
                        switch(this.nameProperty){
                            case 'name':
                                data[record.idProperty] = record.getId();
                                break;
                            case 'mapping':
                                //We make sure, that the mapping exists, 
                               //if not, we fall back to the idProperty.
                                var idName = 
                                       record.fields.get(record.idProperty).mapping 
                                       || 
                                       record.idProperty;
                                data[idName] = record.getId();
                                break;
                        }
    
    
                    }
                }
                return data;
            }
        });
    Bug is also present in 4.1.1 RC2!!!! Easy to fix, so go ahead guys!

  5. #5
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Norway
    Posts
    24
    Vote Rating
    0
    atomcat is on a distinguished road

      0  

    Default


    Hi,

    This issue still seems to be there in EXT 4.1.2a release. Should I file a correct bug report on it? It's an incredibly easy fix, can't understand why it was not done so far.

  6. #6
    Sencha Premium Member
    Join Date
    Mar 2012
    Location
    Norway
    Posts
    24
    Vote Rating
    0
    atomcat is on a distinguished road

      0  

    Default


    Hi!

    Still present in 4.1.3... Code does not work as expected if nameProperty config is set for the writer. Is it so hard to copy-paste a solution into the framework code, or what?

  7. #7
    Ext Premium Member
    Join Date
    Mar 2007
    Location
    Norway
    Posts
    196
    Vote Rating
    3
    bone is on a distinguished road

      0  

    Default


    jesus christ! they never fixed this?
    Founder of the Path of Exticism

  8. #8
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You can configure the nameProperty on the writer to have mappings respected for any field.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!