Opened 8 years ago

Closed 4 years ago

#14206 closed defect (invalid)

dojo.data.ObjectStore.save() problem selecting the request method

Reported by: juanma Owned by: juanma
Priority: high Milestone: 1.11
Component: Data Version: 1.6.1
Keywords: dojo.data.ObjectStore.save() Cc:
Blocked By: Blocking:

Description

I was using a grid with a dojo.store.JsonRest? wrapped with dojo.data.ObjectStore? everything works fine, the problem comes when committing the modifications of the records using the grid.store.save().

Below is the implementation for the function dojo.data.ObjectStore?.save().

When argument _44 is passed to the function dojo.store.JsonRest?.put(), the implementation of this function will look for an id inside the object and use PUT if there is one and POST otherwise. My problem is that the var _44 contains an array containing the object [object], so no id will ever be found and POST will always be selected.

I don't know if im right or im using this the wrong way

function (_38){
	_38=_38||{};
	var _39,_3a=[];
	var _3b={};
	var _3c=[];
	var _3d;
	var _3e=this._dirtyObjects;
	var _3f=_3e.length;
	try{
		dojo.connect(_38,"onError",function(){
			if(_38.revertOnError!==false){
				var _40=_3e;
				_3e=_3c;
				var _41=0;
				jr.revert();
				_3d._dirtyObjects=_40;
			}else{
				_3d._dirtyObjects=dirtyObject.concat(_3c);
			}
		});
		if(this.objectStore.transaction){
			var _42=this.objectStore.transaction();
		}
		for(var i=0;i<_3e.length;i++){
			var _43=_3e[i];
			var _44=_43.object;
			var old=_43.old;
			delete _44.__isDirty;
			if(_44){
Here is my problem--------------------------------<<
                                //var _44 == [object]
				_39=this.objectStore.put(_44,{overwrite:!!old});
			}else{
				_39=this.objectStore.remove(this.getIdentity(old));
			}
				_3c.push(_43);
				_3e.splice(i--,1);
			dojo.when(_39,function(_45){
				if(!(--_3f)){
					if(_38.onComplete){
						_38.onComplete.call(_38.scope,_3a);
					}
				}
			},function(_46){
				_3f=-1;
				_38.onError.call(_38.scope,_46);
			});
		}
		if(_42){
			_42.commit();
		}
	}
	catch(e){
		_38.onError.call(_38.scope,value);
	}
}

Change History (5)

comment:1 Changed 8 years ago by juanma

sorry this is not a real problem, but in this script there is a call to revert() on a undefined variable (jr.revert())

Last edited 8 years ago by juanma (previous) (diff)

comment:2 Changed 8 years ago by bill

Milestone: tbd

comment:3 Changed 7 years ago by Kris Zyp

Are you setting an attribute or create a new item with an array? The variable referenced is supposed to be the object/item that has been set as dirty. I'm curious how it would become an array.

comment:4 Changed 4 years ago by dylan

Milestone: tbd1.11
Owner: changed from Kris Zyp to juanma
Status: newpending

This needs more info to determine if it's still valid. That said, given the changes in the API over the years, I'd suggest trying to repeat this with dstore instead.

comment:5 Changed 4 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.