2009-10-05

Error #3132 in AIR and SQLite Data Types

I was working on an AIR project which makes use of the embedded SQLite database this week and ran into the following error:

Error #3132: Data Type Mismatch.

At first I thought no big deal, I am doing something wrong at the coding level. The code in question was doing an insert on a table and so I thought I was passing the wrong data to the database, but at first glance, I could not see anything wrong. Then I started by removing parts of the columns I was inserting into in order to figure out which one was the problem and I still couldn't figure it out. After some googling and confusion I remembered I changed the data type (from Boolean to Text) on a column on that exact table. So what I did was to drop (delete) the table and re-create it from scratch and voila, problem solved.

So the error was correct, but didn't occur because the data I was passing was incorrect, but because SQLite still thought the data type of the column was a Boolean. Deleting and re-creating the table was the solution.

That brings me to point and wondering if I can get some feedback, I have seen that working Boolean and Timestamp data types in SQLite and AS3 is not working as fluently as it should be, so I use Text and Numeric for each respectively (at the DB level that is). Specifically for date information, I simply do a Date.getTime() in AS3 to get the number of milliseconds since 1970-01-01 and store that, seems to work for me. Anyone else have these problems?