Opened 7 years ago
Last modified 4 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 7 years ago by
Component: | General → DojoX MVC |
---|---|
Owner: | set to Ed Chatelain |
comment:2 Changed 7 years ago by
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 7 years ago by
Component: | DojoX MVC → Data |
---|---|
Owner: | changed from Ed Chatelain to Kris Zyp |
Status: | new → assigned |
Kris?
comment:4 Changed 5 years ago by
Milestone: | tbd → 1.12 |
---|
comment:5 Changed 4 years ago by
Milestone: | 1.13 → 1.15 |
---|
Ticket planning... move current 1.13 tickets out to 1.15 to make it easier to move tickets into the 1.13 milestone.
I don't know if this is an MVC issue or a store issue (or a user error).