Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

um.... i hate git?

  • Loading branch information...
commit 11932c0f7e086dd52367152351fa88778dfa0a9d 1 parent 2b4540f
August "Gus" Mueller ccgus authored
3  CHANGES_AND_TODO_LIST.txt
View
@@ -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  CONTRIBUTORS.txt
View
@@ -26,5 +26,6 @@ Augie Fackler
David E. Wheeler
Casey Fleser
Jeff Meininger
+Pascal Pfiffner
Aaaaannnd, Gus Mueller (that's me!)
2  fmdb.xcodeproj/project.pbxproj
View
@@ -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;
1  src/FMDatabase.h
View
@@ -41,7 +41,6 @@
- (int)lastErrorCode;
- (BOOL)hadError;
- (sqlite_int64)lastInsertRowId;
-- (int)numChanges;
- (sqlite3*)sqliteHandle;
12 src/FMDatabase.m
View
@@ -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
14 src/FMDatabaseAdditions.m
View
@@ -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);
}
14 src/fmdb.m
View
@@ -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"]);
}
-
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.