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 14985 - Specify how autoincrement + empty keypath works
Summary: Specify how autoincrement + empty keypath works
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-29 00:23 UTC by Jonas Sicking (Not reading bugmail)
Modified: 2012-01-24 08:58 UTC (History)
3 users (show)

See Also:


Attachments

Description Jonas Sicking (Not reading bugmail) 2011-11-29 00:23:34 UTC
What should happen for the following calls?

store = db.createObjectStore("mystore", { keyPath: "", autoIncrement: true });
store.add(1);           // store an item with key 1
store.add("foo");       // store an item with key "foo"
store.add({foo:"bar"}); // throw

It seems like if you have a objectStore with an empty keyPath and autoIncrement set to true, you'll either a valid key as the raw value, in which case that value is used as key. Or you'll specify an invalid key as value, in which case we should throw since it's not a valid key. In neither case would we actually use the key generator.

It seems to me that the simplest solution is to not allow an empty keyPath and autoIncrement set to true.

We would of course still allow no keypath and autoIncrement set to true. I.e. we'd still allow out-of-line keys together with autoIncrement. As well as non-empty keypaths with autoincrement set to true.
Comment 1 Jonas Sicking (Not reading bugmail) 2011-11-30 20:10:44 UTC
Fixed, made it throw.
Comment 2 Israel Hilerio [MSFT] 2012-01-13 01:01:11 UTC
Section 3.1.5 needs to be updated to reflect the fact that a valid key path can't be an empty string.  Currently it says:

"A valid key path is either the empty string, a JavaScript identifier, or multiple Javascript identifiers separated by periods"
Comment 3 Jonas Sicking (Not reading bugmail) 2012-01-24 08:58:20 UTC
Empty string is still a valid keyPath, at least for now. You just can't use an empty-string keyPath at the same time as you use a key generator since that is basically useless (see examples in comment 0).

The intent of this bug was just to cover the interaction between empty keypaths and autoincrement.

If we do end up killing empty keypaths that seems like a separate bug, so closing this for now. If we end up killing empty keypaths i'll open a new bug.

Feel free to reopen if you don't agree or if I'm misunderstanding something.