sqlite integer storage issue on iPhone

You must Login before you can answer or comment on any questions.

I want to save large integers (timestamp values) in a database using Titanium 1.6.2. On Android this works fine; on iPhone the value seems to get shortened when written to the db (in the simulator and on a real device). Here's some demonstration code:

var db ='inttest');
db.execute('CREATE TABLE foo (bar INTEGER)');
var t = new Date().getTime();
db.execute('INSERT INTO foo VALUES (?)', t);
var rs = db.execute('SELECT bar FROM foo');
var result = rs.field(0);
alert('written value=' + t + '\nread value=' + result);
On Android, the written and read values are identical. On iPhone, when I write e.g. 1307695588237 to the db, the query returns 2025408156.

I already found that the problem can be fixed by removing the INTEGER type from the CREATE TABLE statement. I was just wondering... does anyone have an idea why this happens, or can at least verify that it happens? I assume that's a TiBug...

Also, I hope this helps anyone who runs into the same problem.

4 Answers


Thank you for sharing the workaround you found. Ticket TIMOB-3050 has been raised to address this issue . Please watch it to show your support for its resolution.


What is the type then if it's not integer?......varchar (256) or something?

— answered 4 years ago by David Lowe
answer permalink
1 Comment
  • Sqlite3 does not use the same data types as you may be accustomed to from other databases. See the discussion here. But the short answer is the type will be TEXT.

    — commented 4 years ago by Doug Handy

I encountered the same issue.
Ti shall have supported the big integer as sqlite3 did. :(

Your Answer

Think you can help? Login to answer this question!