diff --git a/src/ios/SQLitePlugin.m b/src/ios/SQLitePlugin.m index 6406e4bd7..3b3e717a7 100755 --- a/src/ios/SQLitePlugin.m +++ b/src/ios/SQLitePlugin.m @@ -12,7 +12,10 @@ #include +// NOTE: This is now broken by cordova-ios 4.0: +#ifdef READ_BLOB_AS_BASE64 #import +#endif static void sqlite_regexp(sqlite3_context* context, int argc, sqlite3_value** values) { if ( argc < 2 ) { @@ -392,27 +395,31 @@ -(CDVPluginResult*) executeSqlWithDict: (NSMutableDictionary*)options andArgs: ( column_type = sqlite3_column_type(statement, i); switch (column_type) { case SQLITE_INTEGER: - columnValue = [NSNumber numberWithDouble: sqlite3_column_double(statement, i)]; + columnValue = [NSNumber numberWithLongLong: sqlite3_column_int64(statement, i)]; break; - case SQLITE_TEXT: - columnValue = [[NSString alloc] initWithBytes:(char *)sqlite3_column_text(statement, i) - length:sqlite3_column_bytes(statement, i) - encoding:NSUTF8StringEncoding]; -#if !__has_feature(objc_arc) - [columnValue autorelease]; -#endif + case SQLITE_FLOAT: + columnValue = [NSNumber numberWithDouble: sqlite3_column_double(statement, i)]; break; case SQLITE_BLOB: +#ifdef READ_BLOB_AS_BASE64 columnValue = [SQLitePlugin getBlobAsBase64String: sqlite3_column_blob(statement, i) withLength: sqlite3_column_bytes(statement, i)]; #ifdef INCLUDE_SQL_BLOB_BINDING // TBD subjet to change: columnValue = [@"sqlblob:;base64," stringByAppendingString:columnValue]; #endif break; - case SQLITE_FLOAT: - columnValue = [NSNumber numberWithDouble: sqlite3_column_double(statement, i)]; +#endif // else + case SQLITE_TEXT: + columnValue = [[NSString alloc] initWithBytes:(char *)sqlite3_column_text(statement, i) + length:sqlite3_column_bytes(statement, i) + encoding:NSUTF8StringEncoding]; +#if !__has_feature(objc_arc) + [columnValue autorelease]; +#endif break; case SQLITE_NULL: + // just in case (should not happen): + default: columnValue = [NSNull null]; break; } @@ -569,6 +576,7 @@ +(int)mapSQLiteErrorCode:(int)code } } +#ifdef READ_BLOB_AS_BASE64 +(NSString*)getBlobAsBase64String:(const char*)blob_chars withLength:(int)blob_length { @@ -585,5 +593,6 @@ +(NSString*)getBlobAsBase64String:(const char*)blob_chars return result; } +#endif @end /* vim: set expandtab : */