This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 10058 - Specify order for indexes which contain duplicate key values
Summary: Specify order for indexes which contain duplicate key values
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Jonas Sicking (Not reading bugmail)
QA Contact: public-webapps-bugzilla
Depends on:
Reported: 2010-07-01 06:54 UTC by Jonas Sicking (Not reading bugmail)
Modified: 2010-11-08 11:34 UTC (History)
3 users (show)

See Also:


Description Jonas Sicking (Not reading bugmail) 2010-07-01 06:54:51 UTC
Consider an objectStore, with keyPath "id", containing the following objects:

{ id: 1, name: "foo", flags: ["hi", "low"] }
{ id: 2, name: "foo", flags: ["apple", "orange"] }
{ id: 3, name: "goo", flags: ["fahrvergn├╝gen"] }

And an index keyed on the "name" property. What should the following code alert?

results = [];
db.objectStore("myObjectStore").index("nameIndex").openCursor().onsuccess = function(e) {
 cursor = e.result;
 if (!cursor) {

Possible imaginable results are:

In order to keep results consistent and predictable we should define that one of these results are correct, and define which one that is. I would recommend that indexes with duplicate values should be defined to be ordered by the key order in the objectStore. I.e. in this case "1,2,3" would be defined as the correct result.
Comment 1 Jonas Sicking (Not reading bugmail) 2010-11-01 04:50:23 UTC
Working at rewriting cursor handling, especially related to indexes.
Comment 2 Jonas Sicking (Not reading bugmail) 2010-11-08 11:34:56 UTC
Should be fixed by

Would be great if someone could check that it looks correct.