Permalink
Browse files

Examples from davedelong

  • Loading branch information...
1 parent ee222a9 commit c69c9bae7ce25a5ad0a35e6bca67ffe6d66f2c78 @ccgus ccgus committed Apr 30, 2011
Showing with 17 additions and 1 deletion.
  1. +2 −1 src/FMDatabase.m
  2. +15 −0 src/fmdb.m
View
@@ -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
@@ -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));
+ }

0 comments on commit c69c9ba

Please sign in to comment.