W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2007

[whatwg] SQL API complex for simple cases

From: Brady Eidson <beidson@apple.com>
Date: Wed, 31 Oct 2007 12:21:28 -0700
Message-ID: <7DE20607-1EDE-4E7D-98F5-2014E98249F6@apple.com>
I originally had some objections to this, but think it might be okay.

My understanding with this design is that you would get this  
SQLTransaction object back and it would just sit around, not doing  
anything.  When you first call executeSql on it, you kick off the  
transaction steps as they already exist.  Until you call executeSql(),  
it's just a dummy object that doesn't interfere with the database at  

If the above understanding is how we change the spec, I'm all for it.


On Oct 31, 2007, at 11:40 AM, Timothy Hatcher wrote:

> I have finally looked over the new syntax and I'm starting to like  
> how transactions are handled now. However, I feel the current spec  
> has taken a turn towards a more complex model even for simple  
> queries that don't require transactions.
> Compare:
> db.executeSql("CREATE TABLE WebKitStickyNotes (id REAL UNIQUE, note  
> TEXT, timestamp REAL, left TEXT, top TEXT, zindex REAL)", []);
> and
> db.transaction(function(transacion) { transacion.executeSql("CREATE  
> TABLE WebKitStickyNotes (id REAL UNIQUE, note TEXT, timestamp REAL,  
> left TEXT, top TEXT, zindex REAL)", []) });
> I think there needs to be an executeSql on the Database object  
> still. Using executeSql on the Database will just queue up  
> statements interleaved with the transactions.
> The other problem I see that makes the current spec more complex is  
> the transaction callback. I think a better API would be:
> SQLTransaction transaction();
> SQLTransaction transaction(in SQLTransactionErrorCallback  
> errorCallback);
> Then you can call executeSql on the transaction object without  
> having to wait for the callback. Sure, closures in JavaScript make  
> this somewhat less painful, but closures are usually expensive and  
> add additional complexity. Not to mention JavaScript is not the only  
> language that the DOM can be accessed from, for example in WebKit  
> using Objective-C where doing callbacks is a greater hassle.
> ? Timothy Hatcher

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20071031/c1b79035/attachment.htm>
Received on Wednesday, 31 October 2007 12:21:28 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:37 UTC