W3C home > Mailing lists > Public > public-webapps@w3.org > January to March 2012

[IndexedDB] Multientry with invalid keys

From: Jonas Sicking <jonas@sicking.cc>
Date: Fri, 2 Mar 2012 05:20:37 +0100
Message-ID: <CA+c2ei_H6y0x=Vxa=B8cBPPojxN_5ufc1Ayo8fbPo+TjFy7E_g@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
Hi All,

What should we do for the following scenario:

store = db.createObjectStore("store");
index = store.createIndex("index", "x", { multiEntry: true });
store.add({ x: ["a", "b", {}, "c"] }, 1);
index.count().onsuccess = function(event) {
  alert(event.target.result);
}

It's clear that the add should be successful since indexes never add
constraints other than through the explicit 'unique' option. But what
is stored in the index? I.e. what should a multiEntry index do if one
of the items in the array is not a valid key?

Note that this is different from if we had not had a multiEntry index
since in that case the whole array is used as a key and it would
clearly not constitute a valid key. Thus if it was not a multiEntry
index 0 entries would be added to the index.

But for multiEntry indexes we can clearly choose to either reject the
entry completely and not store anything in the index if any of the
elements in the array is not a valid key. Or we could simply skip any
elements that aren't valid keys but insert the other ones.

In other words, 0 or 3 would be possible valid answers to what is
alerted by the script above.

Currently in Firefox we alert 3. In other words we don't reject the
whole array for multiEntry indexes, just the elements that are invalid
keys.

/ Jonas
Received on Friday, 2 March 2012 04:21:34 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:50 GMT