WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
UNCONFIRMED
36089
Web SQL: SQLResultSetRowList does not support indexing of rows
https://bugs.webkit.org/show_bug.cgi?id=36089
Summary
Web SQL: SQLResultSetRowList does not support indexing of rows
Torbjörn Lönnemark
Reported
2010-03-13 11:29:39 PST
Created
attachment 50659
[details]
Test page that doesn't work, but should work.
http://dev.w3.org/html5/webdatabase/
states (as far as I can tell) that SQLResultSetRowList should support indexing of its contained rows, i.e. resultSet.rows[index] should work, but it currently does not in Webkit - you must currently use resultSet.rows.item(index) instead. Tested on version 4.0.4 (531.21.10), nightly build revision 55961. Attached test page displays '0' when indexing works, and is blank otherwise.
Attachments
Test page that doesn't work, but should work.
(916 bytes, text/html)
2010-03-13 11:29 PST
,
Torbjörn Lönnemark
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Matt Bishop
Comment 1
2010-09-16 14:57:43 PDT
I disagree. I don't see anywhere in the html5 webdatabase spec that states the rows object is actually an array. It is very clear about how to get a specific row: "The item(index) attribute must return the row with the given index index." The confusing thing about this spec (see
http://dev.w3.org/html5/webdatabase/#sqlresultsetrowlist
) is that it has methods that make it _look_ like an array but it is not actually a data structure. This bug should be closed.
Chris K
Comment 2
2010-09-19 19:51:02 PDT
Yes, the spec *does* require this: "The object's indices of the supported indexed properties are the numbers in the range zero to length-1, unless the length is zero, in which case there are no supported indexed properties." This is near the bottom of section 4.5.
Matt Bishop
Comment 3
2010-09-19 22:30:39 PDT
Here is the code from the attached test case: db.readTransaction(function (t) { t.executeSql('SELECT COUNT(*) AS c FROM docids', [], function (t, r) { span.textContent = r.rows[0].c; }, function (t, e) { // couldn't read database span.textContent = '(unknown: ' + e.message + ')'; }); }); The correct syntax is: span.textContent = r.rows.item(0).c; SQLResultSetRowList has two methods : item() and length. For a given item(), that "...object's indices of the supported indexed properties are the numbers..." This sentence does not mean that rows is an array, but rather a list of rows with an item() accessor method. The specific row object that is returned by item() does indeed behave like an array If you really feel this is still a bug, please provide another browser that works the way that is described in this bug report.
Chris K
Comment 4
2010-09-20 05:49:49 PDT
The row object is *not* an array -- it is an object whose keys are the database column names: "Each row must be represented by a native ordered dictionary data type. In the JavaScript binding, this must be Object. Each row object must have one property (or dictionary entry) per column, with those properties enumerating in the order that these columns were returned by the database. Each property must have the name of the column and the value of the cell, as they were returned by the database." Opera behaves correctly; run the test case in it and it gives a "0" (correct output).
Luke Stebbing
Comment 5
2013-11-30 15:26:04 PST
SQLResultSetRowList.item is defined as an indexed property getter:
http://www.w3.org/TR/webdatabase/#sqlresultsetrowlist
interface SQLResultSetRowList { readonly attribute unsigned long length; getter any item(in unsigned long index); }; According to Web IDL, this means that rows[0] is equivalent to rows.item(0):
http://www.w3.org/TR/WebIDL/#idl-indexed-properties
Maybe when this was originally implemented, item wasn't an indexed property getter.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug