Skip to content

Commit

Permalink
Merge branch 'common-src' into master-rc ref: #338
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed Sep 10, 2015
2 parents 73993fe + 2bcc633 commit e9d1954
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/ios/SQLitePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

#include <regex.h>

// NOTE: This is now broken by cordova-ios 4.0:
#ifdef READ_BLOB_AS_BASE64
#import <Cordova/NSData+Base64.h>
#endif

static void sqlite_regexp(sqlite3_context* context, int argc, sqlite3_value** values) {
if ( argc < 2 ) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -569,6 +576,7 @@ +(int)mapSQLiteErrorCode:(int)code
}
}

#ifdef READ_BLOB_AS_BASE64
+(NSString*)getBlobAsBase64String:(const char*)blob_chars
withLength:(int)blob_length
{
Expand All @@ -585,5 +593,6 @@ +(NSString*)getBlobAsBase64String:(const char*)blob_chars

return result;
}
#endif

@end /* vim: set expandtab : */

0 comments on commit e9d1954

Please sign in to comment.