Bug 18427 - [IndexedDB] Spec text requires index names be unique within database
[IndexedDB] Spec text requires index names be unique within database
Status: RESOLVED FIXED
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API
unspecified
All All
: P2 normal
: ---
Assigned To: This bug has no owner yet - up for the taking
public-webapps-bugzilla
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-27 21:16 UTC by Joshua Bell
Modified: 2013-01-31 17:47 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joshua Bell 2012-07-27 21:16:22 UTC
The spec sayeth:

createIndex: 
"If an index with the same name already exists, the implementation must throw a DOMException of type ConstraintError."
"An index with the same name, compared in a case-sensitive manner, already exists in the connected database."

deleteIndex: 
"This method destroys the index with the given name in the connected database."
"There is no index with the given name, compared in a case-sensitive manner, in the connected database."

This would appear to require that this should throw ConstraintError:

mozIndexedDB.open("my-db", 1).onupgradeneeded = function(e) {
  db = e.target.result;
  s1 = db.createObjectStore('s1');
  s2 = db.createObjectStore('s2');
  s1.createIndex('i', 'keypath');
  s2.createIndex('i', 'keypath');
};

I don't believe this is the intention of the spec, and neither Firefox (14) nor Chrome (20) behave this way. The uniqueness constraint for index names should be just is within an object store, not across the database. It looks like this is just a copy/pasta from the description/exception tables for create/deleteObjectStore.
Comment 1 Eliot Graff 2012-08-02 21:35:50 UTC
I'll make the change like this:

createIndex: 
"If an index with the name already exists, the implementation must throw a
DOMException of type ConstraintError."
"An index with the same name, compared in a case-sensitive manner, already
exists in the connected object store."

deleteIndex: 
"This method destroys the index with the given name in the connected object store."
"There is no index with the given name, compared in a case-sensitive manner, in
the connected object store."

Thanks,

E
Comment 2 Joshua Bell 2012-08-03 00:52:38 UTC
Looks good, although you can probably remove the word "connected". I think that's there from implying the distinction between the IDBDatabase (the "connection") and the database itself.
Comment 3 Eliot Graff 2013-01-31 17:47:26 UTC
Changes incorporated in commit #377.