Permalink
Browse files

Pre release update

- update to NanoStore 2.5.3
- update nanostore gem version
- add changes
- update Rakefile
  • Loading branch information...
1 parent d5f0de0 commit 61bf3d58913c7f75bbd5786d8633075f3600919b @siuying committed Jan 3, 2013
View
@@ -1,3 +1,9 @@
+# [0.6.0](https://github.com/siuying/NanoStoreInMotion/compare/v0.5.2%E2%80%A6v0.6.0)
+
+- Update for NanoStore 2.5.3, some notable changes:
+ - accept nil and NSURL fields in model
+ - can set store per instance
+
# [0.5.2](https://github.com/siuying/NanoStoreInMotion/compare/v0.5.1%E2%80%A6v0.5.2)
- Fix load error on older version of RubyMotion (or that disabled detect_dependencies)
View
@@ -33,7 +33,7 @@ Motion::Project::App.setup do |app|
# Add the pod NanoStore to your project
app.pods do
- pod 'NanoStore', '~> 2.1.8'
+ pod 'NanoStore', '~> 2.5.3'
end
end
```
View
@@ -9,7 +9,7 @@ Motion::Project::App.setup do |app|
app.redgreen_style = :full
app.files += Dir.glob(File.join(app.project_dir, 'lib/nano_store/*.rb'))
app.pods do
- pod 'NanoStore', '~> 2.5.2'
+ pod 'NanoStore', '~> 2.5.3'
end
end
View
@@ -16,5 +16,5 @@
app.files.unshift(File.join(File.dirname(__FILE__), 'nano_store/finder.rb'))
app.pods ||= Motion::Project::CocoaPods.new(app)
- app.pods.pod 'NanoStore', '~> 2.5.2'
+ app.pods.pod 'NanoStore', '~> 2.5.3'
end
View
@@ -50,11 +50,7 @@ def attribute(name)
end
define_method((name + "=").to_sym) do |*args, &block|
- if args[0].nil?
- self.info.delete(name.to_sym)
- else
- self.info[name] = args[0]
- end
+ self.info[name] = args[0]
end
end
@@ -1,3 +1,3 @@
module NanoStore
- VERSION = "0.5.2"
+ VERSION = "0.6.0"
end
View
@@ -109,6 +109,14 @@ def stub_user(name, age, created_at)
user2.key.should == user.key
end
+ it "create with nil field" do
+ user = stub_user("Bob", 10, nil)
+ user.save
+
+ user1 = User.find(:name, NSFEqualTo, "Bob").first
+ user1.name.should == "Bob"
+ user1.created_at.should.be.nil
+ end
end
describe "#delete" do
View
@@ -1,11 +1,11 @@
PODS:
-- NanoStore (2.5.2)
+- NanoStore (2.5.3)
DEPENDENCIES:
-- NanoStore (~> 2.5.2)
+- NanoStore (~> 2.5.3)
SPEC CHECKSUMS:
- NanoStore: eb22a867411f5ecdf3c959ba58fecd8b8af90e2b
+ NanoStore: ea3eabc945dbd7d80678da2b0aed669f683d239f
COCOAPODS: 0.16.0
@@ -45,23 +45,19 @@
#pragma mark -
-@implementation NSFNanoEngine
-{
-@protected
- sqlite3 *sqlite;
- NSString *path;
- NSFCacheMethod cacheMethod;
-
- /** \cond */
- NSMutableDictionary *schema;
- BOOL willCommitChangeSchema;
- unsigned int busyTimeout;
- /** \endcond */
-}
+@interface NSFNanoEngine ()
+
+/** \cond */
+@property (nonatomic, weak) sqlite3 *sqlite;
+@property (nonatomic, copy, readwrite) NSString *path;
+@property (nonatomic) NSMutableDictionary *schema;
+@property (nonatomic) BOOL willCommitChangeSchema;
+@property (nonatomic) unsigned int busyTimeout;
+/** \endcond */
+
+@end
-@synthesize sqlite;
-@synthesize path;
-@synthesize cacheMethod;
+@implementation NSFNanoEngine
#pragma mark -
@@ -87,7 +83,7 @@ - (id)initWithPath:(NSString *)thePath
userInfo:nil]raise];
if ((self = [self init])) {
- path = [thePath copy];
+ _path = thePath;
}
return self;
@@ -103,8 +99,8 @@ + (void)initialize
- (id)init
{
if ((self = [super init])) {
- path = nil;
- schema = nil;
+ _path = nil;
+ _schema = nil;
}
return self;
}
@@ -126,7 +122,7 @@ - (NSFOrderedDictionary *)dictionaryDescription
NSFOrderedDictionary *values = [NSFOrderedDictionary new];
values[@"SQLite address"] = [NSString stringWithFormat:@"%p", self.sqlite];
- values[@"Database path"] = path;
+ values[@"Database path"] = _path;
values[@"Cache method"] = [self NSFP_cacheMethodToString];
return values;
@@ -148,7 +144,7 @@ - (NSString *)JSONDescription
- (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)useFastMode
{
- int status = sqlite3_open_v2( [path UTF8String], &sqlite,
+ int status = sqlite3_open_v2( [_path UTF8String], &_sqlite,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_AUTOPROXY | SQLITE_OPEN_FULLMUTEX, NULL);
// Set NanoStoreEngine's page size to match the system current page size
@@ -166,7 +162,7 @@ - (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)use
if ((SQLITE_OK != status) || (sqlite3_extended_result_codes(self.sqlite, 1) != SQLITE_OK))
return NO;
- if ([[path lowercaseString]isEqualToString:NSFMemoryDatabase] == YES) {
+ if ([[_path lowercaseString]isEqualToString:NSFMemoryDatabase] == YES) {
sqlite3_exec(self.sqlite, "PRAGMA fullfsync = OFF;", NULL, NULL, NULL);
sqlite3_exec(self.sqlite, "PRAGMA temp_store = MEMORY", NULL, NULL, NULL);
@@ -192,7 +188,7 @@ - (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)use
}
// Save whether we want data to be fetched lazily
- cacheMethod = theCacheMethod;
+ _cacheMethod = theCacheMethod;
[self setBusyTimeout:250];
@@ -229,7 +225,7 @@ - (BOOL)close
}
int status = sqlite3_close(self.sqlite);
- sqlite = NULL;
+ _sqlite = NULL;
// Since we're operating with extended result code support, extract the bits
// and obtain the regular result code
@@ -252,7 +248,7 @@ - (BOOL)beginTransaction
if (YES == [self isTransactionActive])
return NO;
- willCommitChangeSchema = NO;
+ _willCommitChangeSchema = NO;
return [self beginDeferredTransaction];
}
@@ -262,41 +258,41 @@ - (BOOL)beginDeferredTransaction
if (YES == [self isTransactionActive])
return NO;
- willCommitChangeSchema = NO;
+ _willCommitChangeSchema = NO;
return [self NSFP_beginTransactionMode:@"BEGIN DEFERRED TRANSACTION;"];
}
- (BOOL)commitTransaction
{
if (NO == [self isTransactionActive]) {
- willCommitChangeSchema = NO;
+ _willCommitChangeSchema = NO;
return NO;
}
- if (NO == willCommitChangeSchema)
+ if (NO == _willCommitChangeSchema)
[self NSFP_uninstallCommitCallback];
BOOL success = (nil == [[self executeSQL:@"COMMIT TRANSACTION;"]error]);
- if (NO == willCommitChangeSchema)
+ if (NO == _willCommitChangeSchema)
[self NSFP_installCommitCallback];
- willCommitChangeSchema = NO;
+ _willCommitChangeSchema = NO;
return success;
}
- (BOOL)rollbackTransaction
{
if ([self isTransactionActive] == NO) {
- willCommitChangeSchema = NO;
+ _willCommitChangeSchema = NO;
return NO;
}
BOOL success = (nil == [[self executeSQL:@"ROLLBACK TRANSACTION;"]error]);
- willCommitChangeSchema = NO;
+ _willCommitChangeSchema = NO;
return success;
}
@@ -717,14 +713,9 @@ - (void)setBusyTimeout:(unsigned int)theTimeout
theTimeout = 250;
}
- busyTimeout = theTimeout;
+ _busyTimeout = theTimeout;
- sqlite3_busy_timeout(self.sqlite, busyTimeout);
-}
-
-- (unsigned int)busyTimeout
-{
- return busyTimeout;
+ sqlite3_busy_timeout(self.sqlite, _busyTimeout);
}
+ (NSInteger)systemPageSize
@@ -1078,7 +1069,7 @@ + (NSArray *)NSFP_sharedROWIDKeywords
- (NSString *)NSFP_cacheMethodToString
{
- switch (cacheMethod) {
+ switch (_cacheMethod) {
case CacheAllData:
return @"Cache all data";
break;
@@ -1190,8 +1181,8 @@ - (NSFNanoDatatype)NSFP_datatypeForTable:(NSString *)table column:(NSString *)co
NSString *datatype = nil;
// Check to see if the schema has been cached; take advantage of it if possible...
- if (nil != schema) {
- datatype = [[schema objectForKey:table]objectForKey:column];
+ if (nil != _schema) {
+ datatype = [[_schema objectForKey:table]objectForKey:column];
if (nil == datatype) datatype = NSFStringFromNanoDataType(NSFNanoTypeUnknown);
} else {
NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT %@ from %@ WHERE %@ = '%@' AND %@ = '%@';", NSFP_DatatypeIdentifier, NSFP_SchemaTable, NSFP_TableIdentifier, table, NSFP_ColumnIdentifier, column];
@@ -1202,14 +1193,14 @@ - (NSFNanoDatatype)NSFP_datatypeForTable:(NSString *)table column:(NSString *)co
if (nil == datatype) datatype = NSFStringFromNanoDataType(NSFNanoTypeUnknown);
- NSMutableDictionary *tempSchema = [schema objectForKey:table];
+ NSMutableDictionary *tempSchema = [_schema objectForKey:table];
if (nil != tempSchema)
tempSchema = [[NSMutableDictionary alloc]init];
else
;
[tempSchema setObject:datatype forKey:column];
- [schema setObject:tempSchema forKey:table];
+ [_schema setObject:tempSchema forKey:table];
tempSchema = nil;
}
@@ -1513,8 +1504,8 @@ - (BOOL)NSFP_removeColumn:(NSString *)column fromTable:(NSString *)table
- (void)NSFP_rebuildDatatypeCache
{
// Cleanup
- schema = nil;
- schema = [[NSMutableDictionary alloc]init];
+ _schema = nil;
+ _schema = [[NSMutableDictionary alloc]init];
NSArray *tables = [self NSFP_flattenAllTables];
if ([tables count] == 0)
@@ -1535,7 +1526,7 @@ - (void)NSFP_rebuildDatatypeCache
[tableDictionary setObject:[datatypes objectAtIndex:j] forKey:[columns objectAtIndex:j]];
}
- [schema setObject:tableDictionary forKey:table];
+ [_schema setObject:tableDictionary forKey:table];
}
}
@@ -1738,8 +1729,8 @@ - (BOOL)NSFP_isColumnROWIDAlias:(NSString *)column forTable:(NSString *)table
NSString *rowUIDDatatype = NSFStringFromNanoDataType(NSFNanoTypeRowUID);
- if (nil != schema)
- return [[[schema objectForKey:table]objectForKey:column]isEqualToString:rowUIDDatatype];
+ if (nil != _schema)
+ return [[[_schema objectForKey:table]objectForKey:column]isEqualToString:rowUIDDatatype];
NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT %@ FROM %@ WHERE %@ = '%@' AND %@ = '%@';", NSFP_DatatypeIdentifier, NSFP_SchemaTable, NSFP_TableIdentifier, table, NSFP_ColumnIdentifier, column];
NSFNanoResult* result = [self executeSQL:theSQLStatement];
Oops, something went wrong.

0 comments on commit 61bf3d5

Please sign in to comment.