Browse Source

um.... i hate git?

August Mueller 15 years ago
parent
commit
11932c0f7e
7 changed files with 22 additions and 25 deletions
  1. 3 0
      CHANGES_AND_TODO_LIST.txt
  2. 1 0
      CONTRIBUTORS.txt
  3. 2 0
      fmdb.xcodeproj/project.pbxproj
  4. 0 1
      src/FMDatabase.h
  5. 4 8
      src/FMDatabase.m
  6. 7 7
      src/FMDatabaseAdditions.m
  7. 5 9
      src/fmdb.m

+ 3 - 0
CHANGES_AND_TODO_LIST.txt

@@ -3,6 +3,9 @@ Zip, nada, zilch.  Got any ideas?
 
 If you would like to contribute some code- awesome!  I just ask that you make it conform to the coding conventions already set in here, and to add a couple of tests for your new code to fmdb.m.  And of course, the code should be of general use to more than just a couple of folks.  Send your patches to gus@flyingmeat.com.
 
+2011.02.05
+    The -(int)changes; method on FMDatabase is a bit more robust now, and there's a new static library target.  And if a database path is nil, we now open up a :memory: database. Patch from Pascal Pfiffner!
+
 2011.01.13
     Happy New Year!
     Now checking for SQLITE_LOCKED along with SQLITE_BUSY when trying to perform a query.  Patch from Jeff Meininger!

+ 1 - 0
CONTRIBUTORS.txt

@@ -26,5 +26,6 @@ Augie Fackler
 David E. Wheeler
 Casey Fleser
 Jeff Meininger
+Pascal Pfiffner
 
 Aaaaannnd, Gus Mueller (that's me!)

+ 2 - 0
fmdb.xcodeproj/project.pbxproj

@@ -275,6 +275,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
+				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -289,6 +290,7 @@
 		1DEB927A08733DD40010E9CD /* Release */ = {
 			isa = XCBuildConfiguration;
 			buildSettings = {
+				GCC_C_LANGUAGE_STANDARD = c99;
 				GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;

+ 0 - 1
src/FMDatabase.h

@@ -41,7 +41,6 @@
 - (int)lastErrorCode;
 - (BOOL)hadError;
 - (sqlite_int64)lastInsertRowId;
-- (int)numChanges;
 
 - (sqlite3*)sqliteHandle;
 

+ 4 - 8
src/FMDatabase.m

@@ -43,7 +43,7 @@ - (sqlite3*)sqliteHandle {
 }
 
 - (BOOL)open {
-	if (NULL != db) {
+	if (db) {
 		return YES;
 	}
 	
@@ -214,7 +214,7 @@ - (sqlite_int64)lastInsertRowId {
     return ret;
 }
 
-- (int)numChanges {
+- (int)changes {
 	if (inUse) {
         [self compainAboutInUse];
         return 0;
@@ -227,7 +227,7 @@ - (int)numChanges {
     return ret;
 }
 
-- (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt; {
+- (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt {
     
     if ((!obj) || ((NSNull *)obj == [NSNull null])) {
         sqlite3_bind_null(pStmt, idx);
@@ -704,7 +704,7 @@ - (void)setShouldCacheStatements:(BOOL)value {
     }
 }
 
-- (NSMutableDictionary *) cachedStatements {
+- (NSMutableDictionary *)cachedStatements {
     return cachedStatements;
 }
 
@@ -716,10 +716,6 @@ - (void)setCachedStatements:(NSMutableDictionary *)value {
 }
 
 
-- (int)changes {
-    return(sqlite3_changes(db));
-}
-
 @end
 
 

+ 7 - 7
src/FMDatabaseAdditions.m

@@ -23,31 +23,31 @@ @implementation FMDatabase (FMDatabaseAdditions)
 return ret;
 
 
-- (NSString*)stringForQuery:(NSString*)query, ...; {
+- (NSString*)stringForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSString *, stringForColumnIndex);
 }
 
-- (int)intForQuery:(NSString*)query, ...; {
+- (int)intForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(int, intForColumnIndex);
 }
 
-- (long)longForQuery:(NSString*)query, ...; {
+- (long)longForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(long, longForColumnIndex);
 }
 
-- (BOOL)boolForQuery:(NSString*)query, ...; {
+- (BOOL)boolForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(BOOL, boolForColumnIndex);
 }
 
-- (double)doubleForQuery:(NSString*)query, ...; {
+- (double)doubleForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(double, doubleForColumnIndex);
 }
 
-- (NSData*)dataForQuery:(NSString*)query, ...; {
+- (NSData*)dataForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSData *, dataForColumnIndex);
 }
 
-- (NSDate*)dateForQuery:(NSString*)query, ...; {
+- (NSDate*)dateForQuery:(NSString*)query, ... {
     RETURN_RESULT_FOR_QUERY_WITH_SELECTOR(NSDate *, dateForColumnIndex);
 }
 

+ 5 - 9
src/fmdb.m

@@ -135,6 +135,10 @@ int main (int argc, const char * argv[]) {
     // test out the convenience methods in +Additions
     [db executeUpdate:@"create table t1 (a integer)"];
     [db executeUpdate:@"insert into t1 values (?)", [NSNumber numberWithInt:5]];
+    
+    NSLog(@"Count of changes (should be 1): %d", [db changes]);
+    FMDBQuickCheck([db changes] == 1);
+    
     int a = [db intForQuery:@"select a from t1 where a = ?", [NSNumber numberWithInt:5]];
     if (a != 5) {
         NSLog(@"intForQuery didn't work (a != 5)");
@@ -334,7 +338,7 @@ int main (int argc, const char * argv[]) {
     
     [db executeUpdate:@"create table nulltest2 (s text, d data, i integer, f double, b integer)"];
     
-    [db executeUpdate:@"insert into nulltest2 (s, d, i, f, b) values (?, ?, ?, ?, ?)" , @"Hi", safariCompass, [NSNumber numberWithInt:12], [NSNumber numberWithFloat:4.4], [NSNumber numberWithBool:YES]];
+    [db executeUpdate:@"insert into nulltest2 (s, d, i, f, b) values (?, ?, ?, ?, ?)" , @"Hi", safariCompass, [NSNumber numberWithInt:12], [NSNumber numberWithFloat:4.4f], [NSNumber numberWithBool:YES]];
     [db executeUpdate:@"insert into nulltest2 (s, d, i, f, b) values (?, ?, ?, ?, ?)" , nil, nil, nil, nil, [NSNull null]];
     
     rs = [db executeQuery:@"select * from nulltest2"];
@@ -447,12 +451,6 @@ int main (int argc, const char * argv[]) {
         FMDBQuickCheck(strcmp((const char*)[rs UTF8StringForColumnName:@"b"], "two") == 0);
         
         [rs close];
-        
-        
-        
-        
-        
-        
     }
     
     
@@ -466,8 +464,6 @@ int main (int argc, const char * argv[]) {
         while ([rs next]) {
             FMDBQuickCheck([[rs stringForColumn:@"type"] isEqualToString:@"table"]);
         }
-        
-        
     }