I am trying to store NSMutableDictionaries as blobs in sqlite, first converting it to NSData via NSPropertyListSerialization or NSKeyedArchiver.
When I save blob, the length of the NSData object is in thousands (KB range). When I get it back, it was truncated to 10 bytes. When I check the DB through SQLite Browser, most of the data is gone (I can recognize the keys in the record if I store the dictionary as NSPropertyListSerialization, but the dictionary values have disappeared). This happens whether I use NSPropertyListSerialization or NSKeyedArchiver to serialize my data.
NSMutableDictionary* item = [items objectAtIndex:i];
NSData *dictionary = [NSKeyedArchiver archivedDataWithRootObject:item];
sqlite3_bind_blob( compiledStatement, 5, [dictionary bytes], [dictionary length], SQLITE_TRANSIENT);
This is really a snippet from my code, the full section of which I posted in another related question.
Mass insert in sqlite db on iphone
Checking the value [dictionary length] using gdb or NSLog gives the same result: the data length is in the KB range.
When I check the receipt of data later:
NSData* raw = [[NSData alloc] initWithBytes:sqlite3_column_blob(compiledStatement, 1) length:sqlite3_column_bytes(compiledStatement, 1)];
[raw release];
Checking [raw length] gives me only 10 bytes. This is true for every instance of data that I tried to store in this column, regardless of their initial size, in the end they end with 10 bytes. There is nothing wrong with my search. I ran it on the command line and in the SQL browser, and I get the correct records and columns, but the data that was stored in the records for this particular column is incorrect.
? - , sqlite3_bind_blob? sqlite . blob, , .