IndexedDB: fix sort order for indexes

RESOLVED FIXED

Status

()

Core
DOM: IndexedDB
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: sicking, Assigned: sicking)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

5.98 KB, patch
Ben Turner (not reading bugmail, use the needinfo flag!)
: review+
Details | Diff | Splinter Review
Consider the following data. The keypath for the objectStore is "id", and the keyPath for the index is "name".

{ id: 1, name: "a" }
{ id: 2, name: "b" }
{ id: 3, name: "b" }
{ id: 4, name: "b" }
{ id: 5, name: "d" }
{ id: 6, name: "c" }

When creating a cursor on the index, you should get the following results for the following directions of the cursor:

NEXT:
key: "a", primaryKey "1"
key: "b", primaryKey "2"
key: "b", primaryKey "3"
key: "b", primaryKey "4"
key: "c", primaryKey "6"
key: "d", primaryKey "5"

NEXT_NO_DUPLICATE:
key: "a", primaryKey "1"
key: "b", primaryKey "2"
key: "c", primaryKey "6"
key: "d", primaryKey "5"

PREV:
key: "d", primaryKey "5"
key: "c", primaryKey "6"
key: "b", primaryKey "4"
key: "b", primaryKey "3"
key: "b", primaryKey "2"
key: "a", primaryKey "1"

PREV_NO_DUPLICATE:
key: "d", primaryKey "5"
key: "c", primaryKey "6"
key: "b", primaryKey "2"
key: "a", primaryKey "1"


I think currently we get the PREV order wrong. But the PREV_NO_DUPLICATE query seems to execute in a very suboptimal way that doesn't use indexes properly.


I *think* I have ideas for how to write SQL queries that produce this result, feel free to ping me.
Created attachment 572748 [details] [diff] [review]
Patch to fix
Assignee: nobody → jonas
Status: NEW → ASSIGNED
Attachment #572748 - Flags: review?(bent.mozilla)
Comment on attachment 572748 [details] [diff] [review]
Patch to fix

Review of attachment 572748 [details] [diff] [review]:
-----------------------------------------------------------------

Looks great!
Attachment #572748 - Flags: review?(bent.mozilla) → review+
Checked in https://hg.mozilla.org/mozilla-central/rev/504d3127b9a6

Thanks again for such a quick review!
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Component: DOM → DOM: IndexedDB
Version: Trunk → unspecified
You need to log in before you can comment on or make changes to this bug.