Skip to content

Commit

Permalink
um.... i hate git?
Browse files Browse the repository at this point in the history
  • Loading branch information
ccgus committed Feb 5, 2011
1 parent 2b4540f commit 11932c0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CHANGES_AND_TODO_LIST.txt
Expand Up @@ -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!
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -26,5 +26,6 @@ Augie Fackler
David E. Wheeler
Casey Fleser
Jeff Meininger
Pascal Pfiffner

Aaaaannnd, Gus Mueller (that's me!)
2 changes: 2 additions & 0 deletions fmdb.xcodeproj/project.pbxproj
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/FMDatabase.h
Expand Up @@ -41,7 +41,6 @@
- (int)lastErrorCode;
- (BOOL)hadError;
- (sqlite_int64)lastInsertRowId;
- (int)numChanges;

- (sqlite3*)sqliteHandle;

Expand Down
12 changes: 4 additions & 8 deletions src/FMDatabase.m
Expand Up @@ -43,7 +43,7 @@ - (sqlite3*)sqliteHandle {
}

- (BOOL)open {
if (NULL != db) {
if (db) {
return YES;
}

Expand Down Expand Up @@ -214,7 +214,7 @@ - (sqlite_int64)lastInsertRowId {
return ret;
}

- (int)numChanges {
- (int)changes {
if (inUse) {
[self compainAboutInUse];
return 0;
Expand All @@ -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);
Expand Down Expand Up @@ -704,7 +704,7 @@ - (void)setShouldCacheStatements:(BOOL)value {
}
}

- (NSMutableDictionary *) cachedStatements {
- (NSMutableDictionary *)cachedStatements {
return cachedStatements;
}

Expand All @@ -716,10 +716,6 @@ - (void)setCachedStatements:(NSMutableDictionary *)value {
}


- (int)changes {
return(sqlite3_changes(db));
}

@end


Expand Down
14 changes: 7 additions & 7 deletions src/FMDatabaseAdditions.m
Expand Up @@ -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);
}

Expand Down
14 changes: 5 additions & 9 deletions src/fmdb.m
Expand Up @@ -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)");
Expand Down Expand Up @@ -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"];
Expand Down Expand Up @@ -447,12 +451,6 @@ int main (int argc, const char * argv[]) {
FMDBQuickCheck(strcmp((const char*)[rs UTF8StringForColumnName:@"b"], "two") == 0);

[rs close];






}


Expand All @@ -466,8 +464,6 @@ int main (int argc, const char * argv[]) {
while ([rs next]) {
FMDBQuickCheck([[rs stringForColumn:@"type"] isEqualToString:@"table"]);
}


}


Expand Down

0 comments on commit 11932c0

Please sign in to comment.