Bug 138504 - [IndexedDB] array index keys are concatenated across cursor lifetime
Summary: [IndexedDB] array index keys are concatenated across cursor lifetime
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All iOS 8.1
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-11-07 07:47 PST by Chris Anderson
Modified: 2015-06-16 13:25 PDT (History)
9 users (show)

See Also:


Attachments
Patch (5.62 KB, patch)
2014-12-12 14:12 PST, Mark Dixon
no flags Details | Formatted Diff | Diff
Patch (5.62 KB, patch)
2014-12-12 17:55 PST, Mark Dixon
beidson: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Anderson 2014-11-07 07:47:15 PST
The following test passes in Firefox and Chrome but not Safari (Safari v8 Engine: WebKit v600.1.25 OS: Mac OS X v10.10 and Mobile Safari v8 Engine: WebKit v600.1.4 OS: iOS v10.10)

http://requirebin.com/?gist=fcc75007aa20e504bcd4

multiEntry works fine when the members of the multiEntry array are numbers, but when they are arrays, everything goes sideways. It looks like the arrays are being flattened and concated. My test case only uses one layer of nesting but I discovered it in an application that uses multiple layers of nesting (I'm converting deep objects to nested arrays so I can have a defined collation over objects when used as keys.)
Comment 1 Chris Anderson 2014-11-07 09:26:39 PST
Oh dear, it's much worse than I thought. Here is the same bug triggered without multiEntry: http://requirebin.com/?gist=4395a44d50f3c6dddcb8
Comment 2 Chris Anderson 2014-11-07 09:35:40 PST
Good news is this might be a presentation concern, as the results come back in the correct order at least.
Comment 3 Chris Anderson 2014-11-07 12:41:02 PST
Maybe this helps diagnose or helps others with workarounds:

In my case I know all my keys are 2 element arrays. And the cursor starts with a new correct key on the first row of every transaction.

So if your keys are big, paginate. And know how many elements are in your array keys, and then you can run key.splice(-n) where n is your array key length.

It doesn't flatten it just concats.
Comment 4 Mark Dixon 2014-12-12 14:12:15 PST
Created attachment 243214 [details]
Patch
Comment 5 Mark Dixon 2014-12-12 17:55:36 PST
Created attachment 243238 [details]
Patch
Comment 6 Radar WebKit Bug Importer 2015-02-02 09:11:33 PST
<rdar://problem/19684902>
Comment 7 Nolan Lawson 2015-06-08 17:29:26 PDT
Those RequireBin tests weren't working for me, so I browserified them.

You can open these two links, and if it's green, then they pass, and if it's red, they fail:

* http://bl.ocks.org/nolanlawson/b23876ee55085ebb4696
* http://bl.ocks.org/nolanlawson/fa4f74be1810d726db8a

I'm seeing successes in Chrome 43 and Firefox 38, but failures in Safari 8.0.7 and Webkit nightly r185316 (all on desktop Yosemite).
Comment 8 Brady Eidson 2015-06-11 11:16:00 PDT
Comment on attachment 243238 [details]
Patch

It would be useful to check through any of the currently disabled IDB tests to see if this fixes them - Reenabling them would be preferable to changing this test.
Comment 9 Brady Eidson 2015-06-16 13:21:24 PDT
Since Mark isn't around to respond, I just tried the entire suite of IDB tests and this did not change behavior on any of the skipped tests.

Therefore the included change seems appropriate to me.

r+, will prep for landing.
Comment 10 Brady Eidson 2015-06-16 13:25:49 PDT
http://trac.webkit.org/changeset/185604