PDA

View Full Version : [FIXED-EXTJSIV-1975][4.0.0] Getter in BelongsToAssociation does not cache result



mberrie
18 May 2011, 2:52 AM
The generated Getter in BelongsToAssociation does not cache the result of the (asynchronous) load operation.

A BelongsTo association will generate a Getter to obtain the associated model instance. The getter will return the result immediately if the data is available (already loaded), otherwise it will trigger a load on the proxy if not.
The load is (of course) asynchronous and requires a callback to obtain the loaded object. However, the model (instance) that is loaded is never associated with the model on which the Getter method was called.

On any subsequent calls of the getter on the same model instance, it will trigger the load operation again.

First I was not sure if this was actually intended behavior, but checking the docs in BelongsToAssociation#createGetter again, it seems indeed that the instance should be cached:



* @private
* Returns a getter function to be placed on the owner model's prototype. We cache the loaded instance
* the first time it is loaded so that subsequent calls to the getter always receive the same reference.
* @return {Function} The getter function
*/



Since search is disabled I couldn't find if this has been reported before.

If this has not been reported yet, I will gladly provide details and a test case.

Btw there is no store involved, only two models that each have a proxy defined.

mberrie
19 May 2011, 3:34 AM
Had a quick look at the 4.0.1 source - situation unchanged.

evant
20 May 2011, 1:24 AM
This will be resolved in the next patch release.

edspencer
20 May 2011, 12:25 PM
Evan let's make sure there's a way to clear the cached reference too