Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Examples from davedelong

  • Loading branch information...
commit c69c9bae7ce25a5ad0a35e6bca67ffe6d66f2c78 1 parent ee222a9
@ccgus ccgus authored
Showing with 17 additions and 1 deletion.
  1. +2 −1  src/FMDatabase.m
  2. +15 −0 src/fmdb.m
View
3  src/FMDatabase.m
@@ -298,6 +298,7 @@ - (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt {
}
- (void)_extractSQL:(NSString *)sql argumentsList:(va_list)args intoString:(NSMutableString *)cleanedSQL arguments:(NSMutableArray *)arguments {
+
NSUInteger length = [sql length];
unichar last = '\0';
for (NSUInteger i = 0; i < length; ++i) {
@@ -309,7 +310,7 @@ - (void)_extractSQL:(NSString *)sql argumentsList:(va_list)args intoString:(NSMu
case '@':
arg = va_arg(args, id); break;
case 'c':
- arg = [NSNumber numberWithChar:va_arg(args, char)]; break;
+ arg = [NSString stringWithFormat:@"%c", va_arg(args, char)]; break;
case 's':
arg = [NSString stringWithUTF8String:va_arg(args, char*)]; break;
case 'd':
View
15 src/fmdb.m
@@ -467,6 +467,21 @@ int main (int argc, const char * argv[]) {
}
+ {
+ FMDBQuickCheck([db executeUpdate:@"create table t5 (a text, b int, c blob, d text, e text)"]);
+ FMDBQuickCheck(([db executeUpdateWithFormat:@"insert into t5 values (%s, %d, %@, %c, %lld)", "text", 42, @"BLOB", 'd', 12345678901234]));
+
+ rs = [db executeQueryWithFormat:@"select * from t5 where a = %s", "text"];
+ FMDBQuickCheck((rs != nil));
+
+ [rs next];
+
+ FMDBQuickCheck([[rs stringForColumn:@"a"] isEqualToString:@"text"]);
+ FMDBQuickCheck(([rs intForColumn:@"b"] == 42));
+ FMDBQuickCheck([[rs stringForColumn:@"c"] isEqualToString:@"BLOB"]);
+ FMDBQuickCheck([[rs stringForColumn:@"d"] isEqualToString:@"d"]);
+ FMDBQuickCheck(([rs longLongIntForColumn:@"e"] == 12345678901234));
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.