[whatwg] SQL API and database versioning

Scott Hess shess at google.com
Thu Oct 11 09:35:54 PDT 2007


I think I agree with this.  Apps should either use the database in a
versioned form, or an unversioned form, but never both.  Insofar as
there is some subset of the database which is trustworthy to use in
unversioned form, it should be easy enough to just spin up a separate
unversioned database for that.

Actually, I don't quite understand why simply having the empty string
be a version isn't sufficient.  If you don't want to bother with
versioning, always use the empty string (or make the parameter
optional).  If you do want versioning, then it's likely that you don't
want the versioning to be advisory, which is what allowing the empty
string to match anything does.

It may be worthwhile to allow the version to be an array.  Then the
app could easily say "Open this database, and here is the set of
versions I understand."  That operation could be wrapped in a helper
function which runs through the open calls catching exceptions, but it
seems like something reasonable to just bake into the API, because if
you have database versioning, you're almost certainly going to have
multiple outstanding database versions (unlike with a server-side app,
you have little control over when a client executes your app).

-scott


On 10/10/07, Brady Eidson <beidson at apple.com> wrote:
> openDatabase() is called with a database name and an expected version
> string.
>
> If the database has a version, and it is different than the expected
> version, openDatabase() fails.  This makes sense.  But...
>
> "Otherwise, if the database version is the empty string, or if the
> database doesn't yet exist, or if the database exists and the version
> provided to the openDatabase() method is the same as the current
> version associated with the database, then the method must return a
> Database object..."
>
> 1 of these 3 situations doesn't make sense.  A database without a
> version should not be considered valid if the caller to openDatabase()
> expects a version.
>
> This seems silly as two callers, one expecting "versionFoo" of a
> database and the other expecting "versionBar" will both be allowed
> access to a versionless database.
> That seems like an instant recipe for failure for at least versionFoo
> or versionBar, possibly both.
>
> I think that if someone opens a database with an expected version and
> the database already exists but has an empty version string, the
> openDatabase() call should fail.
>
> ~Brady
>



More information about the whatwg mailing list