Bugzilla – Bug 18502
[IndexedDB] Editorial: Wording around IDBFactory.open() with no version misleading
Last modified: 2013-03-01 19:48:04 UTC
The second paragraph reads:
"If no version is specified and a database exists, use the current database version and follow the steps for opening a database. If no version is specified and no database exists, set database version to 1, follow the steps for opening a database, and return a database without object stores."
The most glaring issue is the final phrase, "return a database without object stores" - the function returns an IDBRequest, not a database. The intent is also redundant with step 4 of the "Steps for opening a database".
The phrase "set database version to 1" may also be misleading. More correctly it should follow the phrasing used in the first paragraph which define the inputs to the steps, e.g. "If no version is specified and no database exists, let /origin/ be the origin of the IDBEnvironment used to access this IDBFactory, let /name/ be the name parameter passed to this function, and let /version/ be 1."
(There also seems to be some ambiguity about what happens if open() is called without a version but is delayed by a deleteDatabase(); the delete should happen first, but does the open() use the version the database had prior to the delete? If so, that's a little odd. If not, then the version can't logically be determined at this point in the spec, and must be deferred to the "Steps for opening" e.g. by having the /version/ be null with special cases. I may just be missing something in the spec, though.)
Here's how I think this needs to be fixed:
In both 3.2.3 IDBFactory.open and 3.3.1 IDBFactorySync.open, add this to the end of the first paragraph:
"If no /version/ argument was passed to this function, let /version/ be |undefined|."
And delete the second paragraph, "If no version.... without object stores."
Then in 4.1 Opening a database, insert a new step between steps 4 and 5:
X. If /version/ is |undefined|, then let /version/ be 1 if /db/ was created in the previous step, or the current _version_ of /db/ otherwise.
Fixed in https://dvcs.w3.org/hg/IndexedDB/rev/3662e5052bc0
Since I filed this, I'd appreciate another set of eyeballs to verify the change.