Opened 7 years ago

Closed 6 years ago

#15303 closed defect (wontfix)

JsonRestStore accepts items from different store

Reported by: haysmark Owned by: Kris Zyp
Priority: undecided Milestone: tbd
Component: DojoX Data Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by haysmark)

Consider the following JsonRestStore? code:

connect.connect(rpcRest._index,"onUpdate",this,function(obj,attrName,oldValue,newValue){
	var prefix = this.service.servicePath;
	if(!obj.__id){
		console.log("no id on updated object ", obj);
	}else if(obj.__id.substring(0,prefix.length) == prefix){
		this.onSet(obj,attrName,oldValue,newValue);
	}
});

That is: whenever dojox.rpc gets an onUpdate, call onSet if the start of the object's url matches this url.

The problem is that there may be different rest methods assigned to similar URLs. For example, imagine you have two stores: one pointing at rest method /A, and another at /A/B. Suppose you invoke POST /A/B/1. Because the item's URL matches both /A and /A/B, both stores will have onSet called even though only /A/B was updated.

Change History (3)

comment:1 Changed 7 years ago by haysmark

Description: modified (diff)

comment:2 Changed 7 years ago by haysmark

We should be able to improve the situation by also looking at the suffix, for instance:

}else if(obj.__id.substring(0,prefix.length) == prefix
    && obj.__id.substring(prefix.length)==obj[this.idAttribute]){

This way the item would only match if the suffix contained precisely the object's id.

comment:3 Changed 6 years ago by Colin Snover

Resolution: wontfix
Status: newclosed

dojox/data is abandoned. Some dojox/data stores have been upgraded to use the Dojo Store API and can be found at https://github.com/kfranqueiro/dojo-smore.

Note: See TracTickets for help on using tickets.