I have an ACTIVITY entity that has been created this way:
CREATE TABLE ACTIVITY (ID INTEGER PRIMARY KEY, TYPE TEXT, DESCRIPTION TEXT);
I'm trying to save an Activity object in the Sqlite3 database this way:
func save(database:COpaquePointer) -> Int
{
let id = getMaxActivityId(database) + 1;
let insertQuery = "INSERT INTO ACTIVITY (TYPE, ID, DESCRIPTION) VALUES (?,?,?);"
var statement:COpaquePointer = nil
if sqlite3_prepare_v2(database, insertQuery, -1, &statement, nil) == SQLITE_OK
{
sqlite3_bind_text(statement, 1,type, -1, nil)
sqlite3_bind_int(statement, 2, Int32(id))
sqlite3_bind_text(statement, 3, description ?? "", -1, nil)
}
if sqlite3_step(statement) != SQLITE_DONE
{
let e = NSException(name: "Failed to insert Activity", reason: nil, userInfo: nil)
e.raise()
}
sqlite3_finalize(statement)
return id
}
The values are:
activity.type = "Walking"
activity.id = 12
activity.description = Optional(nil)
When retrieving the data it seems to be inconsistent, and if I try downloading the app container and checking the database, I can see that in the type field, a BLOB type is being inserted instead of a string:
If I try changing the type to "text" it shows this message:
The app I'm using is "Sqlite Browser" 3.8.0 for Os X.


