Opened 8 years ago

Closed 7 years ago

#12670 closed defect (fixed)

Second Argument of observe listener function is wrong when items are sorted

Reported by: ctulek Owned by: Kris Zyp
Priority: high Milestone: 1.7
Component: Data Version: 1.6.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

Browser Type: Any
Browser Version: Any
OS: Any

Try the following code:

var memory = new dojo.store.Memory();
var observer = new dojo.store.Observable(memory);
var query = observer.query(null, {sort: [{attribute: "order"}]});
query.observe(function(item, removedFrom, insertedInto) {
    console.log(arguments);
    if(removedFrom > -1){ // existing object removed
    }
    if(insertedInto > -1){ // new or updated object inserted
    }
}, true);
memory.put({id: 1, order: 1, text: "Test 1"});
memory.put({id: 2, order: 2, text: "Test 2"});
memory.put({id: 3, order: 4, text: "Test 3"});
memory.put({id: 4, order: 3, text: "Test 4"});
memory.put({id: 5, order: 5, text: "Test 5"});
var item = memory.get(3);
item.order = 5;
memory.put(item);

Output:

[ Object , -1, 0]
[ Object , -1, 1]
[ Object , -1, 2]
[ Object , -1, 2]
[ Object , -1, 4]
[ Object , 2, 3] // This is wrong

Expected Output:

[ Object , -1, 0]
[ Object , -1, 1]
[ Object , -1, 2]
[ Object , -1, 2]
[ Object , -1, 4]
[ Object , 4, 3]

Change History (5)

comment:1 Changed 8 years ago by bill

Component: QueryData
Owner: changed from alex to Kris Zyp

comment:2 Changed 7 years ago by Christian Schröder

For the record:

if anyone stumbles upon this bug. It is fixed by this change http://bugs.dojotoolkit.org/changeset/26097/dojo

It looks like is not yet merged with 1.7 trunk

Last edited 7 years ago by Christian Schröder (previous) (diff)

comment:3 Changed 7 years ago by bill

I'm not sure what your comment means:

It looks like is not yet merged with 1.7 trunk

Trunk and 1.7 are two different things, and regardless a change from four months ago is surely in the 1.7.0 tag, the 1.7 branch, and trunk.

Last edited 7 years ago by bill (previous) (diff)

comment:4 Changed 7 years ago by Christian Schröder

Oh sorry, i meant branch. And yes the changeset is included, it just changed even more and i could not find it.

Please excuse the confusion caused.

comment:5 Changed 7 years ago by bill

Description: modified (diff)
Milestone: tbd1.7
Resolution: fixed
Status: newclosed

No worries, OK I am marking this as fixed in 1.7.

Note: See TracTickets for help on using tickets.