Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

[BUG] doubles being truncated in db resultsets on Android

I make a DB and copy it to the Resources dir:

twitch% sqlite ~/foo.db
-- Loading resources from /home/dae/.sqliterc
SQLite version 3.6.16
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table foo(col numeric(10,2));
sqlite> insert into foo values (12345678.9123456);
sqlite> insert into foo values (128058.889475825);

Run the following code:

var db = Ti.Database.install("foo.db", "androidbug");
var r = db.execute("select col from foo");
while (r && r.isValidRow()) {

On the iPhone it prints the correct values as expected. On Android the numbers are off:

[INFO] [10,997] 1.23457e+07
[INFO] [2,999] 128059

Looking at titanium_mobile/android/modules/database/src/ti/modules/titanium/database/TiResultSetProxy.java, it seems that all results are being obtained with getString(). Perhaps getString() is casting the result as a single-precision float? There is also a getDouble() method, so some sort of auto-detection magic may be necessary here.

— asked April 17th 2010 by Damien Elmes
  • bug
  • database
  • float

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.