Hybrid View

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    1
    stephenr85 is on a distinguished road

      0  

    Default Can't have more than one association instance of the same model

    Can't have more than one association instance of the same model


    Architect doesn't expose the associatedName config for associations, which causes the cached property to be "{ModelName}BelongsToInstance", creating a conflict when you want to association multiple models of the same type.

    For now, I've overcome this by overriding the getInstanceName methods of the associations to use the associationKey, if it's available, i.e.:

    Code:
    Ext.define('Ext.data.association.override.BelongsTo', {
        override: 'Ext.data.association.BelongsTo',
    	getInstanceName:function(){
    		var assKey = this.getAssociationKey();
    		return assKey ? assKey+'BelongsToInstance' : me.callParent();
    	}
    });

  2. #2
    Sencha Premium Member
    Join Date
    Dec 2009
    Location
    Rhode Island
    Posts
    228
    Vote Rating
    23
    dmulcahey will become famous soon enough dmulcahey will become famous soon enough

      1  

    Default


    There is a property called instanceName for hasOne associations. It isn't exposed by default in SA but if you type it in to the search area for configs like this: instanceName:'someInstanceName' and click add SA will add it for you as a custom property. If you give each instance of a hasOne association a seperate instanceName it should let you have multiple hasOne associations to the same model.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    1
    stephenr85 is on a distinguished road

      0  

    Default


    Thanks for the tip! I must admit my eyes have skipped over that field for a while now. From looking at the code/docs, I think associatedName is the intended config variable for this, or possibly the fallback (instanceName isn't mentioned in the docs). I think this is still a low-priority bug for Architect, which should expose a config variable to prevent overlapping the "cache" keys.

Thread Participants: 1

Tags for this Thread