Opened 5 years ago

Last modified 3 years ago

#17784 assigned defect

Duplicated data with auto-generated IDs

Reported by: User# Owned by: Kris Zyp
Priority: undecided Milestone: 1.15
Component: Data Version: 1.9.2
Keywords: Cc:
Blocked By: Blocking:

Description

Hello,

A problem occurs when I try to commit data with auto-generated IDs into the store. The first data is duplicated after the 2nd commit etc.

define(['dojox/mvc/EditStoreRefListController',
        'dojo/store/Memory'],
function(EditStoreRefListController,
         Memory) {
return {
	
	beforeActivate: function() {
		var model = new EditStoreRefListController({ store: new Memory({ data: { items: [{ foo: 'value1a', bar: 'value1b' }] } }) });
		model.queryStore(function() { return true; });
		console.log(model.model.length);	// 1: ok
		console.log(model.store.data.length);	// 1: ok

		model.model.push(new Stateful({ foo: 'value2a', bar: 'value2b' }));
		console.log(model.model.length);	// 2: ok
		console.log(model.store.data.length);	// 1: ok

		model.commit();
		console.log(model.model.length);	// 2: ok
		console.log(model.store.data.length);	// 3: KO
	}
	
};
});

In this example, the object { foo: 'value1a', bar: 'value1b' } is duplicated because the auto-generated ID hasn't be pushed into the model by dojo (it appears only in the store).

According to me, there are 2 options:

  • Make compulsory to have an "ID" property defined in order to call "commit" (exception otherwise)
  • Push the generated ID back into the model after generation into the store

The current behavior isn't logic: Dojo seems to have an "auto ID generation" feature but it doesn't work well.

Change History (5)

comment:1 Changed 5 years ago by bill

Component: GeneralDojoX MVC
Owner: set to Ed Chatelain

I don't know if this is an MVC issue or a store issue (or a user error).

comment:2 Changed 5 years ago by Akira Sudoh

Seems that the most straightforward way to fix this problem is the initialisation code of dojo/store/Memory (.setData()) auto-generate the ID, so that it’s consistent with .put(). Needs a feedback of dojo/store/Memory maintainer.

comment:3 Changed 5 years ago by bill

Component: DojoX MVCData
Owner: changed from Ed Chatelain to Kris Zyp
Status: newassigned

Kris?

comment:4 Changed 3 years ago by dylan

Milestone: tbd1.12

comment:5 Changed 3 years ago by dylan

Milestone: 1.131.15

Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.

Note: See TracTickets for help on using tickets.