- From: Joshua Bell <jsbell@chromium.org>
- Date: Fri, 2 Mar 2012 09:15:00 -0800
- To: Webapps WG <public-webapps@w3.org>
- Message-ID: <CAD649j46ayzr+eY1x-R5RQm2=PNXum8k6qxYhhoSGf0BtLZHLw@mail.gmail.com>
On Thu, Mar 1, 2012 at 8:29 PM, Jonas Sicking <jonas@sicking.cc> wrote: > Hi All, > > What should we do if an array which is used for a multiEntry index > contains multiple entries with the same value? I.e. consider the > following code: > > store = db.createObjectStore("store"); > index1 = store.createIndex("index1", "a", { multiEntry: true }); > index2 = store.createIndex("index2", "b", { multiEntry: true, unique: true > }); > store.add({ a: ["x", "x"]}, 1); > store.add({ b: ["y", "y"]}, 2); > > Does either of these adds fail? It seems clear that the first add > should not fail since it doesn't add any explicit constraints. But you > could somewhat make an argument that that the second add should fail > since the two entries would collide. The spec is very vague on this > issue right now. > > However the first add really couldn't add two entries to index1 since > that would produce two entries with the same key and primaryKey. I.e. > there would be no way to distinguish them. > > Hence it seems to me that the second add shouldn't attempt to add two > entries either, and so the second add should succeed. > > This is how Firefox currently behave. I.e. the above code results in > the objectStore containing two entries, and each of the indexes > containing one. > > If this sounds ok to people I'll make this more explicit in the spec. That sounds good to me. FWIW, that matches the results from current builds of Chromium. -- Josh
Received on Friday, 2 March 2012 17:15:33 UTC