[whatwg] Comments on updated SQL API

Maciej Stachowiak mjs at apple.com
Sat Sep 22 00:24:01 PDT 2007


Mostly I like the new API (no surprise to Ian I'm sure).

http://www.whatwg.org/specs/web-apps/current-work/#sql

A few comments. I think putting the currentRow accessors directly on  
the ResultSet is a bit of an odd choice. It seems like it could be  
confusing that myResultSet[0] returns the value of the first field of  
the current row, rather than the first row. At the very least I think  
there should be a currentRow field pointing to a ResultRow object that  
has the accessors. Also, ResultRow could have item, namedItem and  
getName marked DontEnum to allow for..in to be used to get the field  
names, which is more idiomatic JavaScript than the getName method.

Another suggestion is that having a rows array might be more  
convenient than the combination of next(), validRow, and whatever  
accessors exist in the current row (either a separate object or the  
ResultSet could have array-like accessors). The tradeoff for the  
convenience is that you'd have to either cache any already visited  
rows in the ResultSet object (at minimum), since database cursors  
typically only offer iteration in one direction. This one is less  
obvious to me since iterating with next() is not all that inconvenient.

Regards,
Maciej




More information about the whatwg mailing list