I'm able to initialize and populate an database using the Gears
Database API but am having a problem interrogating the ResultSet
obtained by querying the database.
Specifically, the value of any non-numeric attributes are showing up
as "NaN".
So, for example, using the Javacript based Gears API, I can create a
table with the following SQL
create table if not exists testtable
( idx integer primary key asc,
textfield varchar,
intfield integer,
doubfield double )
which I populate with
insert into testtable (idx, textfield, intfield, doubfield) values
( 1, 'this is a test', 2, 3.1)
Using a Java JDBC-based utility, I can interrogate the SQLite DB Gears
creates on the local file system to confirm the data exists.
When I run the following code:
var query = 'select idx, textfield, intfield, doubfield from testtable
where idx=1';
var result = db.execute( query );
if ( result.isValidRow( ) ) {
alert( "Result of select: " + result.field(0) + ", " +
+ result.field(1) + ",
" +
+ result.field(2) + ",
" +
+ result.field(3) );
}
The values of fields 0,1,2 and 3 of the ResultSet are as follows:
1, NaN, 2 and 3.1
The Gears Database API documentation (http://code.google.com/apis/
gears/api_database.html#ResultSet-field) indicates that the return
type of the call to field(index) is "variant".
It seems to be expecting a numeric value rather than adjusting to the
type of the corresponding attribute.
Am I missing something simple?