Skip to content

Commit

Permalink
Opens a :memory: database if databasePath is nil
Browse files Browse the repository at this point in the history
  • Loading branch information
p2 committed Feb 3, 2011
1 parent 22b8626 commit 6809d43
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions fmdb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
/* Begin PBXFileReference section */
08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
32A70AAB03705E1F00C91783 /* fmdb_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fmdb_Prefix.pch; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* fmdb */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = fmdb; sourceTree = BUILT_PRODUCTS_DIR; };
8DD76FA10486AA7600D96B5E /* fmdb */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fmdb; sourceTree = BUILT_PRODUCTS_DIR; };
C6859EA3029092ED04C91782 /* fmdb.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = fmdb.1; sourceTree = "<group>"; };
CC50F2CB0DF9183600E4AAAE /* FMDatabaseAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = FMDatabaseAdditions.m; path = src/FMDatabaseAdditions.m; sourceTree = "<group>"; };
CC50F2CC0DF9183600E4AAAE /* FMDatabaseAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FMDatabaseAdditions.h; path = src/FMDatabaseAdditions.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -277,6 +277,7 @@
1DEB927908733DD40010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
Expand All @@ -303,7 +304,6 @@
GCC_OPTIMIZATION_LEVEL = 0;
PREBINDING = NO;
PRODUCT_NAME = FMDB;
SDKROOT = iphoneos;
};
name = Debug;
};
Expand All @@ -316,7 +316,6 @@
GCC_ENABLE_FIX_AND_CONTINUE = NO;
PREBINDING = NO;
PRODUCT_NAME = FMDB;
SDKROOT = iphoneos;
ZERO_LINK = NO;
};
name = Release;
Expand Down
8 changes: 4 additions & 4 deletions src/FMDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ - (BOOL)open {
return YES;
}

int err = sqlite3_open([databasePath fileSystemRepresentation], &db );
int err = sqlite3_open((databasePath ? [databasePath fileSystemRepresentation] : ":memory:"), &db );
if(err != SQLITE_OK) {
NSLog(@"error opening!: %d", err);
return NO;
Expand All @@ -58,7 +58,7 @@ - (BOOL)open {

#if SQLITE_VERSION_NUMBER >= 3005000
- (BOOL)openWithFlags:(int)flags {
int err = sqlite3_open_v2([databasePath fileSystemRepresentation], &db, flags, NULL /* Name of VFS module to use */);
int err = sqlite3_open_v2((databasePath ? [databasePath fileSystemRepresentation] : ":memory:"), &db, flags, NULL /* Name of VFS module to use */);
if(err != SQLITE_OK) {
NSLog(@"error opening!: %d", err);
return NO;
Expand Down Expand Up @@ -375,7 +375,7 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray*)arr
}
}

// the statement gets close in rs's dealloc or [rs close];
// the statement gets closed in rs's dealloc or [rs close];
rs = [FMResultSet resultSetWithStatement:statement usingParentDatabase:self];
[rs setQuery:sql];

Expand Down Expand Up @@ -403,7 +403,7 @@ - (FMResultSet *)executeQuery:(NSString *)sql withArgumentsInArray:(NSArray *)ar
}

- (BOOL)executeUpdate:(NSString*)sql error:(NSError**)outErr withArgumentsInArray:(NSArray*)arrayArgs orVAList:(va_list)args {

if (inUse) {
[self compainAboutInUse];
return NO;
Expand Down

0 comments on commit 6809d43

Please sign in to comment.