nano-store 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGELOG → CHANGELOG.md} +7 -0
- data/README.md +5 -1
- data/Rakefile +1 -1
- data/lib/nano_store.rb +1 -1
- data/lib/nano_store/finder.rb +10 -2
- data/lib/nano_store/model.rb +7 -7
- data/lib/nano_store/version.rb +1 -1
- data/spec/association_spec.rb +6 -6
- data/spec/finder_spec.rb +2 -0
- data/spec/model_spec.rb +33 -3
- data/spec/nano_store_spec.rb +5 -0
- data/spec/spec_helper.rb +14 -0
- data/vendor/Podfile.lock +3 -3
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoBag.h +6 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoEngine.h +5 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoEngine_Private.h +2 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoExpression.h +6 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoExpression_Private.h +1 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals.h +5 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals_Private.h +6 -2
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoObject.h +15 -3
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoObject_Private.h +4 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoPredicate.h +6 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoResult.h +5 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSearch.h +16 -2
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSortDescriptor.h +7 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoStore.h +12 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoStore_Private.h +3 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NSFOrderedDictionary.h +33 -0
- data/vendor/Pods/BuildHeaders/NanoStore/NanoStore.h +36 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoBag.h +6 -1
- data/vendor/Pods/Headers/NanoStore/NSFNanoEngine.h +5 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoEngine_Private.h +2 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoExpression.h +6 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoExpression_Private.h +1 -1
- data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals.h +5 -1
- data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals_Private.h +6 -2
- data/vendor/Pods/Headers/NanoStore/NSFNanoObject.h +15 -3
- data/vendor/Pods/Headers/NanoStore/NSFNanoObject_Private.h +4 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoPredicate.h +6 -1
- data/vendor/Pods/Headers/NanoStore/NSFNanoResult.h +5 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoSearch.h +16 -2
- data/vendor/Pods/Headers/NanoStore/NSFNanoSortDescriptor.h +7 -1
- data/vendor/Pods/Headers/NanoStore/NSFNanoStore.h +12 -0
- data/vendor/Pods/Headers/NanoStore/NSFNanoStore_Private.h +3 -1
- data/vendor/Pods/Headers/NanoStore/NSFOrderedDictionary.h +33 -0
- data/vendor/Pods/Headers/NanoStore/NanoStore.h +36 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.h +5 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.m +142 -131
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.h +5 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.m +148 -51
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFOrderedDictionary.h +33 -0
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFOrderedDictionary.m +148 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoEngine_Private.h +2 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoExpression_Private.h +1 -1
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoGlobals_Private.h +6 -2
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoObject_Private.h +4 -0
- data/vendor/Pods/NanoStore/Classes/Private/NSFNanoStore_Private.h +3 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.h +6 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.m +126 -117
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.h +6 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.m +32 -18
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.h +5 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.m +6 -3
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.h +15 -3
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m +152 -31
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.h +6 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.m +51 -26
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.h +16 -2
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.m +156 -115
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.h +7 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.m +34 -17
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.h +12 -0
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.m +210 -196
- data/vendor/Pods/NanoStore/Classes/Public/NanoStore.h +36 -0
- data/vendor/Pods/NanoStore/README.md +49 -0
- data/vendor/Pods/Pods.bridgesupport +798 -685
- metadata +30 -8
@@ -25,10 +25,12 @@
|
|
25
25
|
*/
|
26
26
|
|
27
27
|
#import "NSFNanoStore.h"
|
28
|
+
#import "NSFOrderedDictionary.h"
|
28
29
|
|
29
30
|
/** \cond */
|
30
31
|
|
31
32
|
@interface NSFNanoStore (Private)
|
33
|
+
- (NSFOrderedDictionary *)dictionaryDescription;
|
32
34
|
+ (NSFNanoStore *)_createAndOpenDebugDatabase;
|
33
35
|
- (NSFNanoResult *)_executeSQL:(NSString *)theSQLStatement;
|
34
36
|
- (NSString*)_nestedDescriptionWithPrefixedSpace:(NSString *)prefixedSpace;
|
@@ -37,7 +39,7 @@
|
|
37
39
|
- (void)_setIsOurTransaction:(BOOL)value;
|
38
40
|
- (BOOL)_isOurTransaction;
|
39
41
|
- (BOOL)_setupCachingSchema;
|
40
|
-
- (BOOL)_storeDictionary:(NSDictionary *)someInfo forKey:(NSString *)aKey forClassNamed:(NSString *)classType
|
42
|
+
- (BOOL)_storeDictionary:(NSDictionary *)someInfo forKey:(NSString *)aKey forClassNamed:(NSString *)classType error:(out NSError **)outError;
|
41
43
|
- (BOOL)__storeDictionaries:(NSArray *)someObjects forKeys:(NSArray *)someKeys error:(out NSError **)outError;
|
42
44
|
- (BOOL)_bindValue:(id)aValue forAttribute:(NSString *)anAttribute parameterNumber:(NSInteger)aParamNumber usingSQLite3Statement:(sqlite3_stmt *)aStatement;
|
43
45
|
- (BOOL)_checkNanoStoreIsReadyAndReturnError:(out NSError **)outError;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
//
|
2
|
+
// NSFOrderedDictionary.h
|
3
|
+
// OrderedDictionary
|
4
|
+
//
|
5
|
+
// Created by Matt Gallagher on 19/12/08.
|
6
|
+
// Copyright 2008 Matt Gallagher. All rights reserved.
|
7
|
+
//
|
8
|
+
// v2 - ARC-compliant (Tito Ciuro)
|
9
|
+
// v1 - Initial release (Matt Gallagher)
|
10
|
+
//
|
11
|
+
// This software is provided 'as-is', without any express or implied
|
12
|
+
// warranty. In no event will the authors be held liable for any damages
|
13
|
+
// arising from the use of this software. Permission is granted to anyone to
|
14
|
+
// use this software for any purpose, including commercial applications, and to
|
15
|
+
// alter it and redistribute it freely, subject to the following restrictions:
|
16
|
+
//
|
17
|
+
// 1. The origin of this software must not be misrepresented; you must not
|
18
|
+
// claim that you wrote the original software. If you use this software
|
19
|
+
// in a product, an acknowledgment in the product documentation would be
|
20
|
+
// appreciated but is not required.
|
21
|
+
// 2. Altered source versions must be plainly marked as such, and must not be
|
22
|
+
// misrepresented as being the original software.
|
23
|
+
// 3. This notice may not be removed or altered from any source
|
24
|
+
// distribution.
|
25
|
+
//
|
26
|
+
|
27
|
+
@interface NSFOrderedDictionary : NSMutableDictionary
|
28
|
+
|
29
|
+
- (void)insertObject:(id)anObject forKey:(id)aKey atIndex:(NSUInteger)anIndex;
|
30
|
+
- (id)keyAtIndex:(NSUInteger)anIndex;
|
31
|
+
- (NSEnumerator *)reverseKeyEnumerator;
|
32
|
+
|
33
|
+
@end
|
@@ -64,6 +64,13 @@
|
|
64
64
|
- iOS library runs on the device and simulator
|
65
65
|
- ARC compliant
|
66
66
|
|
67
|
+
@section latest_changes Latest changes
|
68
|
+
v2.5 - January 1, 2013
|
69
|
+
|
70
|
+
Starting with v2.5, the plist mechanism has been replaced with NSKeyedArchiver. There are several reasons for it: it's more compact, faster and uses less memory. Perhaps the most important reason is that it opens the possibility to store other data types.
|
71
|
+
|
72
|
+
NSNull is now supported. Big thanks to Wanny (https://github.com/mrwanny) for taking the time to improve this section of NanoStore.
|
73
|
+
|
67
74
|
@section installation_sec Installation
|
68
75
|
|
69
76
|
Building NanoStore is very easy. Just follow these steps:
|
@@ -423,6 +430,35 @@
|
|
423
430
|
[sortByLastName release];
|
424
431
|
@endcode
|
425
432
|
|
433
|
+
@section paging_limit_sec Paging using Limit and Offset
|
434
|
+
SQLite provides a really cool feature called OFFSET that is usually used with a LIMIT clause.
|
435
|
+
|
436
|
+
The LIMIT clause is used to limit the number of results returned in a SQL statement. So if you have 1000 rows in table, but only want to return the first 10, you would do something like this:
|
437
|
+
@code
|
438
|
+
SELECT column FROM table LIMIT 10
|
439
|
+
@endcode
|
440
|
+
Now suppose you wanted to show results 11-20. With the OFFSET keyword it's just as easy. The following query will do:
|
441
|
+
@code
|
442
|
+
SELECT column FROM table LIMIT 10 OFFSET 10
|
443
|
+
@endcode
|
444
|
+
Using pagination is also quite easy with NanoStore. This example based on one of the unit tests provided with the NanoStore distro:
|
445
|
+
@code
|
446
|
+
NSFNanoStore *nanoStore = [NSFNanoStore createAndOpenStoreWithType:NSFMemoryStoreType path:nil error:nil];
|
447
|
+
|
448
|
+
// Assume we have added objects to the store
|
449
|
+
|
450
|
+
NSFNanoSearch *search = [NSFNanoSearch searchWithStore:nanoStore];
|
451
|
+
search.value = @"Barcelona";
|
452
|
+
search.match = NSFEqualTo;
|
453
|
+
search.limit = 5;
|
454
|
+
search.offset = 3;
|
455
|
+
|
456
|
+
NSDictionary *searchResults = [search searchObjectsWithReturnType:NSFReturnObjects error:nil];
|
457
|
+
|
458
|
+
// Assuming the query matches some results, NanoStore should have retrieved
|
459
|
+
// the first 5 records right after the 3rd one from the result set.
|
460
|
+
@endcode
|
461
|
+
|
426
462
|
@section performancetips_sec Performance Tips
|
427
463
|
|
428
464
|
NanoStore by defaults saves every object to disk one by one. To speed up inserts and edited objects, increase NSFNanoStore's \link NSFNanoStore::saveInterval saveInterval \endlink property.
|
@@ -26,6 +26,7 @@
|
|
26
26
|
|
27
27
|
#import "NanoStore.h"
|
28
28
|
#import "NanoStore_Private.h"
|
29
|
+
#import "NSFOrderedDictionary.h"
|
29
30
|
|
30
31
|
#import <stdio.h>
|
31
32
|
#import <stdlib.h>
|
@@ -44,23 +45,19 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
44
45
|
|
45
46
|
#pragma mark -
|
46
47
|
|
47
|
-
@
|
48
|
-
{
|
49
|
-
@protected
|
50
|
-
sqlite3 *sqlite;
|
51
|
-
NSString *path;
|
52
|
-
NSFCacheMethod cacheMethod;
|
53
|
-
|
54
|
-
/** \cond */
|
55
|
-
NSMutableDictionary *schema;
|
56
|
-
BOOL willCommitChangeSchema;
|
57
|
-
unsigned int busyTimeout;
|
58
|
-
/** \endcond */
|
59
|
-
}
|
48
|
+
@interface NSFNanoEngine ()
|
60
49
|
|
61
|
-
|
62
|
-
@
|
63
|
-
@
|
50
|
+
/** \cond */
|
51
|
+
@property (nonatomic, weak) sqlite3 *sqlite;
|
52
|
+
@property (nonatomic, copy, readwrite) NSString *path;
|
53
|
+
@property (nonatomic) NSMutableDictionary *schema;
|
54
|
+
@property (nonatomic) BOOL willCommitChangeSchema;
|
55
|
+
@property (nonatomic) unsigned int busyTimeout;
|
56
|
+
/** \endcond */
|
57
|
+
|
58
|
+
@end
|
59
|
+
|
60
|
+
@implementation NSFNanoEngine
|
64
61
|
|
65
62
|
#pragma mark -
|
66
63
|
|
@@ -72,7 +69,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
72
69
|
{
|
73
70
|
if (nil == thePath)
|
74
71
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
75
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
72
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: thePath is nil.", [self class], NSStringFromSelector(_cmd)]
|
76
73
|
userInfo:nil]raise];
|
77
74
|
|
78
75
|
return [[self alloc]initWithPath:thePath];
|
@@ -82,11 +79,11 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
82
79
|
{
|
83
80
|
if (nil == thePath)
|
84
81
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
85
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
82
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: thePath is nil.", [self class], NSStringFromSelector(_cmd)]
|
86
83
|
userInfo:nil]raise];
|
87
84
|
|
88
85
|
if ((self = [self init])) {
|
89
|
-
|
86
|
+
_path = thePath;
|
90
87
|
}
|
91
88
|
|
92
89
|
return self;
|
@@ -102,8 +99,8 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
102
99
|
- (id)init
|
103
100
|
{
|
104
101
|
if ((self = [super init])) {
|
105
|
-
|
106
|
-
|
102
|
+
_path = nil;
|
103
|
+
_schema = nil;
|
107
104
|
}
|
108
105
|
return self;
|
109
106
|
}
|
@@ -111,15 +108,34 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
111
108
|
- (void)dealloc
|
112
109
|
{
|
113
110
|
[self close];
|
114
|
-
|
115
|
-
|
116
111
|
}
|
117
112
|
|
118
113
|
/** \endcond */
|
119
114
|
|
120
|
-
- (NSString*)description
|
115
|
+
- (NSString *)description
|
121
116
|
{
|
122
|
-
return [self
|
117
|
+
return [self JSONDescription];
|
118
|
+
}
|
119
|
+
|
120
|
+
- (NSFOrderedDictionary *)dictionaryDescription
|
121
|
+
{
|
122
|
+
NSFOrderedDictionary *values = [NSFOrderedDictionary new];
|
123
|
+
|
124
|
+
values[@"SQLite address"] = [NSString stringWithFormat:@"%p", self.sqlite];
|
125
|
+
values[@"Database path"] = _path;
|
126
|
+
values[@"Cache method"] = [self NSFP_cacheMethodToString];
|
127
|
+
|
128
|
+
return values;
|
129
|
+
}
|
130
|
+
|
131
|
+
- (NSString *)JSONDescription
|
132
|
+
{
|
133
|
+
NSFOrderedDictionary *values = [self dictionaryDescription];
|
134
|
+
|
135
|
+
NSError *outError = nil;
|
136
|
+
NSString *description = [NSFNanoObject _NSObjectToJSONString:values error:&outError];
|
137
|
+
|
138
|
+
return description;
|
123
139
|
}
|
124
140
|
|
125
141
|
#pragma mark// ==================================
|
@@ -128,7 +144,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
128
144
|
|
129
145
|
- (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)useFastMode
|
130
146
|
{
|
131
|
-
int status = sqlite3_open_v2( [
|
147
|
+
int status = sqlite3_open_v2( [_path UTF8String], &_sqlite,
|
132
148
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_AUTOPROXY | SQLITE_OPEN_FULLMUTEX, NULL);
|
133
149
|
|
134
150
|
// Set NanoStoreEngine's page size to match the system current page size
|
@@ -146,7 +162,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
146
162
|
if ((SQLITE_OK != status) || (sqlite3_extended_result_codes(self.sqlite, 1) != SQLITE_OK))
|
147
163
|
return NO;
|
148
164
|
|
149
|
-
if ([[
|
165
|
+
if ([[_path lowercaseString]isEqualToString:NSFMemoryDatabase] == YES) {
|
150
166
|
|
151
167
|
sqlite3_exec(self.sqlite, "PRAGMA fullfsync = OFF;", NULL, NULL, NULL);
|
152
168
|
sqlite3_exec(self.sqlite, "PRAGMA temp_store = MEMORY", NULL, NULL, NULL);
|
@@ -172,7 +188,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
172
188
|
}
|
173
189
|
|
174
190
|
// Save whether we want data to be fetched lazily
|
175
|
-
|
191
|
+
_cacheMethod = theCacheMethod;
|
176
192
|
|
177
193
|
[self setBusyTimeout:250];
|
178
194
|
|
@@ -209,7 +225,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
209
225
|
}
|
210
226
|
|
211
227
|
int status = sqlite3_close(self.sqlite);
|
212
|
-
|
228
|
+
_sqlite = NULL;
|
213
229
|
|
214
230
|
// Since we're operating with extended result code support, extract the bits
|
215
231
|
// and obtain the regular result code
|
@@ -232,7 +248,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
232
248
|
if (YES == [self isTransactionActive])
|
233
249
|
return NO;
|
234
250
|
|
235
|
-
|
251
|
+
_willCommitChangeSchema = NO;
|
236
252
|
|
237
253
|
return [self beginDeferredTransaction];
|
238
254
|
}
|
@@ -242,7 +258,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
242
258
|
if (YES == [self isTransactionActive])
|
243
259
|
return NO;
|
244
260
|
|
245
|
-
|
261
|
+
_willCommitChangeSchema = NO;
|
246
262
|
|
247
263
|
return [self NSFP_beginTransactionMode:@"BEGIN DEFERRED TRANSACTION;"];
|
248
264
|
}
|
@@ -250,19 +266,19 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
250
266
|
- (BOOL)commitTransaction
|
251
267
|
{
|
252
268
|
if (NO == [self isTransactionActive]) {
|
253
|
-
|
269
|
+
_willCommitChangeSchema = NO;
|
254
270
|
return NO;
|
255
271
|
}
|
256
272
|
|
257
|
-
if (NO ==
|
273
|
+
if (NO == _willCommitChangeSchema)
|
258
274
|
[self NSFP_uninstallCommitCallback];
|
259
275
|
|
260
276
|
BOOL success = (nil == [[self executeSQL:@"COMMIT TRANSACTION;"]error]);
|
261
277
|
|
262
|
-
if (NO ==
|
278
|
+
if (NO == _willCommitChangeSchema)
|
263
279
|
[self NSFP_installCommitCallback];
|
264
280
|
|
265
|
-
|
281
|
+
_willCommitChangeSchema = NO;
|
266
282
|
|
267
283
|
return success;
|
268
284
|
}
|
@@ -270,13 +286,13 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
270
286
|
- (BOOL)rollbackTransaction
|
271
287
|
{
|
272
288
|
if ([self isTransactionActive] == NO) {
|
273
|
-
|
289
|
+
_willCommitChangeSchema = NO;
|
274
290
|
return NO;
|
275
291
|
}
|
276
292
|
|
277
293
|
BOOL success = (nil == [[self executeSQL:@"ROLLBACK TRANSACTION;"]error]);
|
278
294
|
|
279
|
-
|
295
|
+
_willCommitChangeSchema = NO;
|
280
296
|
|
281
297
|
return success;
|
282
298
|
}
|
@@ -359,17 +375,17 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
359
375
|
{
|
360
376
|
if (nil == table)
|
361
377
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
362
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
378
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
363
379
|
userInfo:nil]raise];
|
364
380
|
|
365
381
|
if (nil == columns)
|
366
382
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
367
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
383
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: columns is nil.", [self class], NSStringFromSelector(_cmd)]
|
368
384
|
userInfo:nil]raise];
|
369
385
|
|
370
386
|
if (nil == datatypes)
|
371
387
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
372
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
388
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: datatypes is nil.", [self class], NSStringFromSelector(_cmd)]
|
373
389
|
userInfo:nil]raise];
|
374
390
|
|
375
391
|
return [self NSFP_createTable:table withColumns:columns datatypes:datatypes isTemporary:NO];
|
@@ -379,7 +395,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
379
395
|
{
|
380
396
|
if (nil == table)
|
381
397
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
382
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
398
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
383
399
|
userInfo:nil]raise];
|
384
400
|
|
385
401
|
BOOL transactionSetHere = NO;
|
@@ -411,11 +427,11 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
411
427
|
{
|
412
428
|
if (nil == column)
|
413
429
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
414
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
430
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: column is nil.", [self class], NSStringFromSelector(_cmd)]
|
415
431
|
userInfo:nil]raise];
|
416
432
|
if (nil == table)
|
417
433
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
418
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
434
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
419
435
|
userInfo:nil]raise];
|
420
436
|
|
421
437
|
NSString *theSQLStatement = nil;
|
@@ -434,7 +450,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
434
450
|
{
|
435
451
|
if (nil == indexName)
|
436
452
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
437
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
453
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: indexName is nil.", [self class], NSStringFromSelector(_cmd)]
|
438
454
|
userInfo:nil]raise];
|
439
455
|
|
440
456
|
NSString *theSQLStatement = [[NSString alloc]initWithFormat:@"DROP INDEX %@;", indexName];
|
@@ -483,7 +499,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
483
499
|
{
|
484
500
|
if (nil == table)
|
485
501
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
486
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
502
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
487
503
|
userInfo:nil]raise];
|
488
504
|
|
489
505
|
NSString *theSQLStatement = nil;
|
@@ -506,7 +522,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
506
522
|
{
|
507
523
|
if (nil == table)
|
508
524
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
509
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
525
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
510
526
|
userInfo:nil]raise];
|
511
527
|
|
512
528
|
NSString *theSQLStatement = nil;
|
@@ -536,7 +552,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
536
552
|
{
|
537
553
|
if (nil == table)
|
538
554
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
539
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
555
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
540
556
|
userInfo:nil]raise];
|
541
557
|
|
542
558
|
NSFNanoResult* result = [self executeSQL:[NSString stringWithFormat:@"SELECT sqlite_master.name FROM sqlite_master WHERE type = 'index' AND sqlite_master.tbl_name = '%@';", table]];
|
@@ -558,12 +574,12 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
558
574
|
{
|
559
575
|
if (nil == theSQLStatement)
|
560
576
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
561
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
577
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is nil.", [self class], NSStringFromSelector(_cmd)]
|
562
578
|
userInfo:nil]raise];
|
563
579
|
|
564
580
|
if ([theSQLStatement length] == 0)
|
565
581
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
566
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
582
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is empty.", [self class], NSStringFromSelector(_cmd)]
|
567
583
|
userInfo:nil]raise];
|
568
584
|
|
569
585
|
// Check whether we will need to return a dictionary with results
|
@@ -602,21 +618,36 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
602
618
|
NSString *column = [[NSString alloc]initWithUTF8String:columnUTF8];
|
603
619
|
|
604
620
|
// Sanity check: some queries return NULL, which would cause a crash below.
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
621
|
+
if ([column isEqualToString:@"NSFKeys.NSFKeyedArchive"]) {
|
622
|
+
//KeyedArchive is a blob
|
623
|
+
NSData *dictBinData = [[NSData alloc] initWithBytes:sqlite3_column_blob(theSQLiteStatement, columnIndex) length: sqlite3_column_bytes(theSQLiteStatement, 1)];
|
624
|
+
|
625
|
+
// Obtain the array to collect the values. If the array doesn't exist, create it.
|
626
|
+
NSMutableArray *values = [info objectForKey:column];
|
627
|
+
if (nil == values) {
|
628
|
+
values = [NSMutableArray new];
|
629
|
+
}
|
630
|
+
[values addObject:dictBinData];
|
631
|
+
[info setObject:values forKey:column];
|
632
|
+
}else
|
633
|
+
{
|
634
|
+
char *valueUTF8 = (char *)sqlite3_column_text (theSQLiteStatement, columnIndex);
|
635
|
+
NSString *value = nil;
|
636
|
+
if (NULL != valueUTF8) {
|
637
|
+
value = [[NSString alloc]initWithUTF8String:valueUTF8];
|
638
|
+
} else {
|
639
|
+
value = [[NSNull null]description];
|
640
|
+
}
|
641
|
+
|
642
|
+
// Obtain the array to collect the values. If the array doesn't exist, create it.
|
643
|
+
NSMutableArray *values = [info objectForKey:column];
|
644
|
+
if (nil == values) {
|
645
|
+
values = [NSMutableArray new];
|
646
|
+
}
|
647
|
+
[values addObject:value];
|
648
|
+
[info setObject:values forKey:column];
|
611
649
|
}
|
612
|
-
|
613
|
-
// Obtain the array to collect the values. If the array doesn't exist, create it.
|
614
|
-
NSMutableArray *values = [info objectForKey:column];
|
615
|
-
if (nil == values) {
|
616
|
-
values = [NSMutableArray new];
|
617
|
-
}
|
618
|
-
[values addObject:value];
|
619
|
-
[info setObject:values forKey:column];
|
650
|
+
|
620
651
|
|
621
652
|
// Let's cleanup. This will keep the memory footprint low...
|
622
653
|
}
|
@@ -638,10 +669,10 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
638
669
|
NSFNanoResult *result = nil;
|
639
670
|
|
640
671
|
if (SQLITE_OK != status) {
|
641
|
-
NSString *msg = (NULL != errorMessage) ? [NSString stringWithUTF8String:errorMessage] : [NSString stringWithFormat:@"SQLite error ID: %
|
672
|
+
NSString *msg = (NULL != errorMessage) ? [NSString stringWithUTF8String:errorMessage] : [NSString stringWithFormat:@"SQLite error ID: %d", status];
|
642
673
|
result = [NSFNanoResult _resultWithError:[NSError errorWithDomain:NSFDomainKey
|
643
674
|
code:NSFNanoStoreErrorKey
|
644
|
-
userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"*** -[%@
|
675
|
+
userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"*** -[%@ %@]: %@", [self class], NSStringFromSelector(_cmd), msg]
|
645
676
|
forKey:NSLocalizedFailureReasonErrorKey]]];
|
646
677
|
} else {
|
647
678
|
result = [NSFNanoResult _resultWithDictionary:info];
|
@@ -659,7 +690,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
659
690
|
{
|
660
691
|
if (nil == table) {
|
661
692
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
662
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
693
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is nil.", [self class], NSStringFromSelector(_cmd)]
|
663
694
|
userInfo:nil]raise];
|
664
695
|
}
|
665
696
|
|
@@ -682,14 +713,9 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
682
713
|
theTimeout = 250;
|
683
714
|
}
|
684
715
|
|
685
|
-
|
716
|
+
_busyTimeout = theTimeout;
|
686
717
|
|
687
|
-
sqlite3_busy_timeout(self.sqlite,
|
688
|
-
}
|
689
|
-
|
690
|
-
- (unsigned int)busyTimeout
|
691
|
-
{
|
692
|
-
return busyTimeout;
|
718
|
+
sqlite3_busy_timeout(self.sqlite, _busyTimeout);
|
693
719
|
}
|
694
720
|
|
695
721
|
+ (NSInteger)systemPageSize
|
@@ -908,7 +934,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
908
934
|
{
|
909
935
|
if (nil == data)
|
910
936
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
911
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
937
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: data is nil.", [self class], NSStringFromSelector(_cmd)]
|
912
938
|
userInfo:nil]raise];
|
913
939
|
|
914
940
|
NSInteger decodedDataSize = [data length];
|
@@ -983,7 +1009,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
983
1009
|
{
|
984
1010
|
if (nil == encodedData)
|
985
1011
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
986
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1012
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: encodedData is nil.", [self class], NSStringFromSelector(_cmd)]
|
987
1013
|
userInfo:nil]raise];
|
988
1014
|
|
989
1015
|
const char* source = [encodedData UTF8String];
|
@@ -1043,7 +1069,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1043
1069
|
|
1044
1070
|
- (NSString *)NSFP_cacheMethodToString
|
1045
1071
|
{
|
1046
|
-
switch (
|
1072
|
+
switch (_cacheMethod) {
|
1047
1073
|
case CacheAllData:
|
1048
1074
|
return @"Cache all data";
|
1049
1075
|
break;
|
@@ -1063,26 +1089,11 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1063
1089
|
return (extendedResult & 0x00FF);
|
1064
1090
|
}
|
1065
1091
|
|
1066
|
-
- (NSString*)NSFP_nestedDescriptionWithPrefixedSpace:(NSString *)prefixedSpace
|
1067
|
-
{
|
1068
|
-
if (nil == prefixedSpace) {
|
1069
|
-
prefixedSpace = @"";
|
1070
|
-
}
|
1071
|
-
|
1072
|
-
NSMutableString *description = [NSMutableString string];
|
1073
|
-
[description appendString:@"\n"];
|
1074
|
-
[description appendString:[NSString stringWithFormat:@"%@SQLite address : 0x%x\n", prefixedSpace, self.sqlite]];
|
1075
|
-
[description appendString:[NSString stringWithFormat:@"%@Database path : %@\n", prefixedSpace, path]];
|
1076
|
-
[description appendString:[NSString stringWithFormat:@"%@Cache method : %@\n", prefixedSpace, [self NSFP_cacheMethodToString]]];
|
1077
|
-
|
1078
|
-
return description;
|
1079
|
-
}
|
1080
|
-
|
1081
1092
|
+ (NSDictionary *)_plistToDictionary:(NSString *)aPlist
|
1082
1093
|
{
|
1083
1094
|
if (nil == aPlist)
|
1084
1095
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1085
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1096
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: aPlist is nil.", [self class], NSStringFromSelector(_cmd)]
|
1086
1097
|
userInfo:nil]raise];
|
1087
1098
|
|
1088
1099
|
if ([aPlist length] == 0)
|
@@ -1110,12 +1121,12 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1110
1121
|
{
|
1111
1122
|
if (nil == dest)
|
1112
1123
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1113
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1124
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: dest is nil.", [self class], NSStringFromSelector(_cmd)]
|
1114
1125
|
userInfo:nil]raise];
|
1115
1126
|
|
1116
1127
|
if (nil == src)
|
1117
1128
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1118
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1129
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: src is nil.", [self class], NSStringFromSelector(_cmd)]
|
1119
1130
|
userInfo:nil]raise];
|
1120
1131
|
|
1121
1132
|
NSUInteger x = 0;
|
@@ -1146,7 +1157,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1146
1157
|
{
|
1147
1158
|
if (nil == tableAndColumn)
|
1148
1159
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1149
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1160
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tableAndColumn is nil.", [self class], NSStringFromSelector(_cmd)]
|
1150
1161
|
userInfo:nil]raise];
|
1151
1162
|
|
1152
1163
|
NSString *table = [self NSFP_prefixWithDotDelimiter:tableAndColumn];
|
@@ -1159,19 +1170,19 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1159
1170
|
{
|
1160
1171
|
if (nil == table)
|
1161
1172
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1162
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1173
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
1163
1174
|
userInfo:nil]raise];
|
1164
1175
|
|
1165
1176
|
if (nil == column)
|
1166
1177
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1167
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1178
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: column is nil.", [self class], NSStringFromSelector(_cmd)]
|
1168
1179
|
userInfo:nil]raise];
|
1169
1180
|
|
1170
1181
|
NSString *datatype = nil;
|
1171
1182
|
|
1172
1183
|
// Check to see if the schema has been cached; take advantage of it if possible...
|
1173
|
-
if (nil !=
|
1174
|
-
datatype = [[
|
1184
|
+
if (nil != _schema) {
|
1185
|
+
datatype = [[_schema objectForKey:table]objectForKey:column];
|
1175
1186
|
if (nil == datatype) datatype = NSFStringFromNanoDataType(NSFNanoTypeUnknown);
|
1176
1187
|
} else {
|
1177
1188
|
NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT %@ from %@ WHERE %@ = '%@' AND %@ = '%@';", NSFP_DatatypeIdentifier, NSFP_SchemaTable, NSFP_TableIdentifier, table, NSFP_ColumnIdentifier, column];
|
@@ -1182,14 +1193,14 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1182
1193
|
|
1183
1194
|
if (nil == datatype) datatype = NSFStringFromNanoDataType(NSFNanoTypeUnknown);
|
1184
1195
|
|
1185
|
-
NSMutableDictionary *tempSchema = [
|
1196
|
+
NSMutableDictionary *tempSchema = [_schema objectForKey:table];
|
1186
1197
|
if (nil != tempSchema)
|
1187
1198
|
tempSchema = [[NSMutableDictionary alloc]init];
|
1188
1199
|
else
|
1189
1200
|
;
|
1190
1201
|
|
1191
1202
|
[tempSchema setObject:datatype forKey:column];
|
1192
|
-
[
|
1203
|
+
[_schema setObject:tempSchema forKey:table];
|
1193
1204
|
|
1194
1205
|
tempSchema = nil;
|
1195
1206
|
}
|
@@ -1234,7 +1245,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1234
1245
|
{
|
1235
1246
|
if (nil == aSQLQuery)
|
1236
1247
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1237
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1248
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: aSQLQuery is nil.", [self class], NSStringFromSelector(_cmd)]
|
1238
1249
|
userInfo:nil]raise];
|
1239
1250
|
|
1240
1251
|
// Prepare SQLite's VM. It's placed here so we can speed up stores...
|
@@ -1261,7 +1272,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1261
1272
|
{
|
1262
1273
|
if (nil == theSQLStatement)
|
1263
1274
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1264
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1275
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is nil.", [self class], NSStringFromSelector(_cmd)]
|
1265
1276
|
userInfo:nil]raise];
|
1266
1277
|
|
1267
1278
|
if ([self isTransactionActive] == NO) {
|
@@ -1316,22 +1327,22 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1316
1327
|
{
|
1317
1328
|
if (nil == table)
|
1318
1329
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1319
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1330
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
1320
1331
|
userInfo:nil]raise];
|
1321
1332
|
|
1322
1333
|
if (nil == tableColumns)
|
1323
1334
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1324
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1335
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tableColumns is nil.", [self class], NSStringFromSelector(_cmd)]
|
1325
1336
|
userInfo:nil]raise];
|
1326
1337
|
|
1327
1338
|
if (nil == tableDatatypes)
|
1328
1339
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1329
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1340
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tableDatatypes is nil.", [self class], NSStringFromSelector(_cmd)]
|
1330
1341
|
userInfo:nil]raise];
|
1331
1342
|
|
1332
1343
|
if ([tableColumns count] != [tableDatatypes count])
|
1333
1344
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1334
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1345
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: number of columns and datatypes mismatch.", [self class], NSStringFromSelector(_cmd)]
|
1335
1346
|
userInfo:nil]raise];
|
1336
1347
|
|
1337
1348
|
NSSet *allowedDatatypes = [NSFNanoEngine sharedNanoStoreEngineDatatypes];
|
@@ -1410,12 +1421,12 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1410
1421
|
|
1411
1422
|
if (nil == column)
|
1412
1423
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1413
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1424
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: column is nil.", [self class], NSStringFromSelector(_cmd)]
|
1414
1425
|
userInfo:nil]raise];
|
1415
1426
|
|
1416
1427
|
if (nil == table)
|
1417
1428
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1418
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1429
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
1419
1430
|
userInfo:nil]raise];
|
1420
1431
|
|
1421
1432
|
NSArray *tableInfoColumns = [self columnsForTable:table];
|
@@ -1493,8 +1504,8 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1493
1504
|
- (void)NSFP_rebuildDatatypeCache
|
1494
1505
|
{
|
1495
1506
|
// Cleanup
|
1496
|
-
|
1497
|
-
|
1507
|
+
_schema = nil;
|
1508
|
+
_schema = [[NSMutableDictionary alloc]init];
|
1498
1509
|
|
1499
1510
|
NSArray *tables = [self NSFP_flattenAllTables];
|
1500
1511
|
if ([tables count] == 0)
|
@@ -1515,7 +1526,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1515
1526
|
[tableDictionary setObject:[datatypes objectAtIndex:j] forKey:[columns objectAtIndex:j]];
|
1516
1527
|
}
|
1517
1528
|
|
1518
|
-
[
|
1529
|
+
[_schema setObject:tableDictionary forKey:table];
|
1519
1530
|
}
|
1520
1531
|
}
|
1521
1532
|
|
@@ -1523,17 +1534,17 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1523
1534
|
{
|
1524
1535
|
if (nil == values)
|
1525
1536
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1526
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1537
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: values is nil.", [self class], NSStringFromSelector(_cmd)]
|
1527
1538
|
userInfo:nil]raise];
|
1528
1539
|
|
1529
1540
|
if (nil == columns)
|
1530
1541
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1531
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1542
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: columns is nil.", [self class], NSStringFromSelector(_cmd)]
|
1532
1543
|
userInfo:nil]raise];
|
1533
1544
|
|
1534
1545
|
if (nil == table)
|
1535
1546
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1536
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1547
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
1537
1548
|
userInfo:nil]raise];
|
1538
1549
|
|
1539
1550
|
// Make sure we have specified ROWID in the group of columns
|
@@ -1569,12 +1580,12 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1569
1580
|
{
|
1570
1581
|
if (nil == theSQLStatement)
|
1571
1582
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1572
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1583
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is nil.", [self class], NSStringFromSelector(_cmd)]
|
1573
1584
|
userInfo:nil]raise];
|
1574
1585
|
|
1575
1586
|
if (nil == tags)
|
1576
1587
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1577
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1588
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tags is nil.", [self class], NSStringFromSelector(_cmd)]
|
1578
1589
|
userInfo:nil]raise];
|
1579
1590
|
|
1580
1591
|
NSInteger i, count = [tags count];
|
@@ -1598,12 +1609,12 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1598
1609
|
{
|
1599
1610
|
if (nil == theSQLStatement)
|
1600
1611
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1601
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1612
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is nil.", [self class], NSStringFromSelector(_cmd)]
|
1602
1613
|
userInfo:nil]raise];
|
1603
1614
|
|
1604
1615
|
if (nil == tags)
|
1605
1616
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1606
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1617
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tags is nil.", [self class], NSStringFromSelector(_cmd)]
|
1607
1618
|
userInfo:nil]raise];
|
1608
1619
|
|
1609
1620
|
[self NSFP_sqlString:theSQLStatement appendingTags:tags quoteTags:NO];
|
@@ -1613,22 +1624,22 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1613
1624
|
{
|
1614
1625
|
if (nil == theSQLStatement)
|
1615
1626
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1616
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1627
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: theSQLStatement is nil.", [self class], NSStringFromSelector(_cmd)]
|
1617
1628
|
userInfo:nil]raise];
|
1618
1629
|
|
1619
1630
|
if (nil == table)
|
1620
1631
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1621
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1632
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
1622
1633
|
userInfo:nil]raise];
|
1623
1634
|
|
1624
1635
|
if (nil == columns)
|
1625
1636
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1626
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1637
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: columns is nil.", [self class], NSStringFromSelector(_cmd)]
|
1627
1638
|
userInfo:nil]raise];
|
1628
1639
|
|
1629
1640
|
if (nil == datatypes)
|
1630
1641
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1631
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1642
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: datatypes is nil.", [self class], NSStringFromSelector(_cmd)]
|
1632
1643
|
userInfo:nil]raise];
|
1633
1644
|
|
1634
1645
|
BOOL constructionSucceeded = YES;
|
@@ -1664,12 +1675,12 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1664
1675
|
{
|
1665
1676
|
if (nil == tableColumns)
|
1666
1677
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1667
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1678
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tableColumns is nil.", [self class], NSStringFromSelector(_cmd)]
|
1668
1679
|
userInfo:nil]raise];
|
1669
1680
|
|
1670
1681
|
if (nil == datatypes)
|
1671
1682
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1672
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1683
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: datatypes is nil.", [self class], NSStringFromSelector(_cmd)]
|
1673
1684
|
userInfo:nil]raise];
|
1674
1685
|
|
1675
1686
|
// First check if we have a datatype of type NSFNanoTypeRowUID
|
@@ -1708,18 +1719,18 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1708
1719
|
{
|
1709
1720
|
if (nil == column)
|
1710
1721
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1711
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1722
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: column is nil.", [self class], NSStringFromSelector(_cmd)]
|
1712
1723
|
userInfo:nil]raise];
|
1713
1724
|
|
1714
1725
|
if (nil == table)
|
1715
1726
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1716
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1727
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: table is nil.", [self class], NSStringFromSelector(_cmd)]
|
1717
1728
|
userInfo:nil]raise];
|
1718
1729
|
|
1719
1730
|
NSString *rowUIDDatatype = NSFStringFromNanoDataType(NSFNanoTypeRowUID);
|
1720
1731
|
|
1721
|
-
if (nil !=
|
1722
|
-
return [[[
|
1732
|
+
if (nil != _schema)
|
1733
|
+
return [[[_schema objectForKey:table]objectForKey:column]isEqualToString:rowUIDDatatype];
|
1723
1734
|
|
1724
1735
|
NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT %@ FROM %@ WHERE %@ = '%@' AND %@ = '%@';", NSFP_DatatypeIdentifier, NSFP_SchemaTable, NSFP_TableIdentifier, table, NSFP_ColumnIdentifier, column];
|
1725
1736
|
NSFNanoResult* result = [self executeSQL:theSQLStatement];
|
@@ -1734,7 +1745,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1734
1745
|
{
|
1735
1746
|
if (nil == tableAndColumn)
|
1736
1747
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1737
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1748
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tableAndColumn is nil.", [self class], NSStringFromSelector(_cmd)]
|
1738
1749
|
userInfo:nil]raise];
|
1739
1750
|
|
1740
1751
|
NSRange range = [tableAndColumn rangeOfString:@"." options:NSBackwardsSearch];
|
@@ -1748,7 +1759,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1748
1759
|
{
|
1749
1760
|
if (nil == tableAndColumn)
|
1750
1761
|
[[NSException exceptionWithName:NSFUnexpectedParameterException
|
1751
|
-
reason:[NSString stringWithFormat:@"*** -[%@
|
1762
|
+
reason:[NSString stringWithFormat:@"*** -[%@ %@]: tableAndColumn is nil.", [self class], NSStringFromSelector(_cmd)]
|
1752
1763
|
userInfo:nil]raise];
|
1753
1764
|
|
1754
1765
|
NSRange range = [tableAndColumn rangeOfString:@"." options:NSBackwardsSearch];
|