nano-store 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/Rakefile +1 -1
- data/lib/nano_store.rb +1 -1
- data/lib/nano_store/version.rb +1 -1
- data/nano-store.gemspec +2 -2
- data/vendor/Podfile.lock +3 -3
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals.h +1 -3
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoPredicate.h +5 -5
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSearch.h +3 -5
- data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSortDescriptor.h +1 -1
- data/vendor/Pods/BuildHeaders/NanoStore/NanoStore.h +0 -36
- data/vendor/Pods/Documentation/NanoStore/docset-installed.txt +2 -2
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Info.plist +3 -3
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoBag.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoEngine.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoExpression.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoObject.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoPredicate.html +6 -6
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoResult.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoSearch.html +4 -65
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoSortDescriptor.html +2 -2
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoStore.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFOrderedDictionary.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Protocols/NSFNanoObjectProtocol.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/hierarchy.html +4 -4
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/index.html +4 -4
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Nodes.xml +1 -1
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens5.xml +6 -6
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens7.xml +2 -24
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens8.xml +2 -2
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.dsidx +0 -0
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.skidx +0 -0
- data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.toc +0 -0
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoBag.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoEngine.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoExpression.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoObject.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoPredicate.html +6 -6
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoResult.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoSearch.html +4 -65
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoSortDescriptor.html +2 -2
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoStore.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFOrderedDictionary.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/Protocols/NSFNanoObjectProtocol.html +1 -1
- data/vendor/Pods/Documentation/NanoStore/html/hierarchy.html +4 -4
- data/vendor/Pods/Documentation/NanoStore/html/index.html +4 -4
- data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals.h +1 -3
- data/vendor/Pods/Headers/NanoStore/NSFNanoPredicate.h +5 -5
- data/vendor/Pods/Headers/NanoStore/NSFNanoSearch.h +3 -5
- data/vendor/Pods/Headers/NanoStore/NSFNanoSortDescriptor.h +1 -1
- data/vendor/Pods/Headers/NanoStore/NanoStore.h +0 -36
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.m +49 -40
- data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.m +53 -42
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.m +89 -80
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.m +13 -11
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.h +1 -3
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.m +0 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m +29 -34
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.h +5 -5
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.m +34 -43
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.h +3 -5
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.m +97 -171
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.h +1 -1
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.m +12 -13
- data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.m +82 -83
- data/vendor/Pods/NanoStore/Classes/Public/NanoStore.h +0 -36
- data/vendor/Pods/Pods.bridgesupport +640 -648
- metadata +7 -7
@@ -12,7 +12,7 @@
|
|
12
12
|
<body>
|
13
13
|
<header id="top_header">
|
14
14
|
<div id="library" class="hideInXcode">
|
15
|
-
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.
|
15
|
+
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.2 </a></h1>
|
16
16
|
<a id="developerHome" href="../index.html">Tito Ciuro</a>
|
17
17
|
</div>
|
18
18
|
|
@@ -296,7 +296,7 @@ NSLog(@“%@”, [[object info]objectForKey:@“City”]);
|
|
296
296
|
|
297
297
|
|
298
298
|
|
299
|
-
<div class="method-subsection method-declaration"><code>@property (nonatomic,
|
299
|
+
<div class="method-subsection method-declaration"><code>@property (nonatomic, readonly) NSString *attribute</code></div>
|
300
300
|
|
301
301
|
|
302
302
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<body>
|
13
13
|
<header id="top_header">
|
14
14
|
<div id="library" class="hideInXcode">
|
15
|
-
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.
|
15
|
+
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.2 </a></h1>
|
16
16
|
<a id="developerHome" href="../index.html">Tito Ciuro</a>
|
17
17
|
</div>
|
18
18
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<body>
|
13
13
|
<header id="top_header">
|
14
14
|
<div id="library" class="hideInXcode">
|
15
|
-
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.
|
15
|
+
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.2 </a></h1>
|
16
16
|
<a id="developerHome" href="../index.html">Tito Ciuro</a>
|
17
17
|
</div>
|
18
18
|
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<body>
|
13
13
|
<header id="top_header">
|
14
14
|
<div id="library" class="hideInXcode">
|
15
|
-
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.
|
15
|
+
<h1><a id="libraryTitle" href="../index.html">NanoStore 2.5.2 </a></h1>
|
16
16
|
<a id="developerHome" href="../index.html">Tito Ciuro</a>
|
17
17
|
</div>
|
18
18
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
-
<title>NanoStore 2.5.
|
5
|
+
<title>NanoStore 2.5.2 Hierarchy</title>
|
6
6
|
<link rel="stylesheet" type="text/css" href="css/styles.css" media="all" />
|
7
7
|
<link rel="stylesheet" type="text/css" media="print" href="css/stylesPrint.css" />
|
8
8
|
<meta name="generator" content="appledoc 2.0.5 (build 789)" />
|
@@ -10,12 +10,12 @@
|
|
10
10
|
<body>
|
11
11
|
<header id="top_header">
|
12
12
|
<div id="library" class="hideInXcode">
|
13
|
-
<h1><a id="libraryTitle" href="index.html">NanoStore 2.5.
|
13
|
+
<h1><a id="libraryTitle" href="index.html">NanoStore 2.5.2 </a></h1>
|
14
14
|
<a id="developerHome" href="index.html">Tito Ciuro</a>
|
15
15
|
</div>
|
16
16
|
|
17
17
|
<div id="title" role="banner">
|
18
|
-
<h1 class="hideInXcode">NanoStore 2.5.
|
18
|
+
<h1 class="hideInXcode">NanoStore 2.5.2 Hierarchy</h1>
|
19
19
|
</div>
|
20
20
|
<ul id="headerButtons" role="toolbar"></ul>
|
21
21
|
</header>
|
@@ -26,7 +26,7 @@
|
|
26
26
|
</div>
|
27
27
|
<div id="header">
|
28
28
|
<div class="section-header">
|
29
|
-
<h1 class="title title-header">NanoStore 2.5.
|
29
|
+
<h1 class="title title-header">NanoStore 2.5.2 Hierarchy</h1>
|
30
30
|
</div>
|
31
31
|
</div>
|
32
32
|
<div id="container">
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
-
<title>NanoStore 2.5.
|
5
|
+
<title>NanoStore 2.5.2 Reference</title>
|
6
6
|
<link rel="stylesheet" type="text/css" href="css/styles.css" media="all" />
|
7
7
|
<link rel="stylesheet" type="text/css" media="print" href="css/stylesPrint.css" />
|
8
8
|
<meta name="generator" content="appledoc 2.0.5 (build 789)" />
|
@@ -10,12 +10,12 @@
|
|
10
10
|
<body>
|
11
11
|
<header id="top_header">
|
12
12
|
<div id="library" class="hideInXcode">
|
13
|
-
<h1><a id="libraryTitle" href="index.html">NanoStore 2.5.
|
13
|
+
<h1><a id="libraryTitle" href="index.html">NanoStore 2.5.2 </a></h1>
|
14
14
|
<a id="developerHome" href="index.html">Tito Ciuro</a>
|
15
15
|
</div>
|
16
16
|
|
17
17
|
<div id="title" role="banner">
|
18
|
-
<h1 class="hideInXcode">NanoStore 2.5.
|
18
|
+
<h1 class="hideInXcode">NanoStore 2.5.2 Reference</h1>
|
19
19
|
</div>
|
20
20
|
<ul id="headerButtons" role="toolbar"></ul>
|
21
21
|
</header>
|
@@ -26,7 +26,7 @@
|
|
26
26
|
</div>
|
27
27
|
<div id="header">
|
28
28
|
<div class="section-header">
|
29
|
-
<h1 class="title title-header">NanoStore 2.5.
|
29
|
+
<h1 class="title title-header">NanoStore 2.5.2 Reference</h1>
|
30
30
|
</div>
|
31
31
|
</div>
|
32
32
|
<div id="container">
|
@@ -77,7 +77,7 @@
|
|
77
77
|
/** * The comparison operator to be used. */
|
78
78
|
@property (nonatomic, assign, readonly) NSFMatchType match;
|
79
79
|
/** * The value to be used for comparison. */
|
80
|
-
@property (nonatomic, readonly)
|
80
|
+
@property (nonatomic, copy, readonly) NSString *value;
|
81
81
|
|
82
82
|
/** @name Creating and Initializing a Predicate
|
83
83
|
*/
|
@@ -87,22 +87,22 @@
|
|
87
87
|
/** * Creates and returns a predicate.
|
88
88
|
* @param theType is the column type. Can be \link Globals::NSFKeyColumn NSFKeyColumn \endlink, \link Globals::NSFAttributeColumn NSFAttributeColumn \endlink or \link Globals::NSFValueColumn NSFValueColumn \endlink.
|
89
89
|
* @param theMatch is the match operator.
|
90
|
-
* @param theValue
|
90
|
+
* @param theValue is the value.
|
91
91
|
* @return A predicate which can be used in an NSFNanoExpression.
|
92
92
|
* @see \link initWithColumn:matching:value: - (id)initWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(NSString *)theValue \endlink
|
93
93
|
*/
|
94
94
|
|
95
|
-
+ (NSFNanoPredicate*)predicateWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(
|
95
|
+
+ (NSFNanoPredicate*)predicateWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(NSString *)theValue;
|
96
96
|
|
97
97
|
/** * Initializes a newly allocated predicate.
|
98
98
|
* @param theType is the column type. Can be \link Globals::NSFKeyColumn NSFKeyColumn \endlink, \link Globals::NSFAttributeColumn NSFAttributeColumn \endlink or \link Globals::NSFValueColumn NSFValueColumn \endlink.
|
99
99
|
* @param theMatch is the match operator.
|
100
|
-
* @param theValue
|
100
|
+
* @param theValue is the value.
|
101
101
|
* @return A predicate which can be used in an NSFNanoExpression.
|
102
102
|
* @see \link predicateWithColumn:matching:value: + (NSFNanoPredicate*)predicateWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(NSString *)theValue \endlink
|
103
103
|
*/
|
104
104
|
|
105
|
-
- (id)initWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(
|
105
|
+
- (id)initWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(NSString *)theValue;
|
106
106
|
|
107
107
|
//@}
|
108
108
|
|
@@ -175,13 +175,11 @@
|
|
175
175
|
/** * The sort holds an array of one or more sort descriptors of type \link NSFNanoSortDescriptor NSFNanoSortDescriptor \endlink. */
|
176
176
|
@property (nonatomic, strong, readwrite) NSArray *sort;
|
177
177
|
/** * The filterClass allows to filter the results based on a specific object class. */
|
178
|
-
@property (nonatomic,
|
178
|
+
@property (nonatomic, strong, readwrite) NSString *filterClass;
|
179
179
|
/** * If an expression has an offset clause, then the first M rows are omitted from the result set returned by the search operation and the next N rows are returned, where M and N are the values that the offset and limit clauses evaluate to, respectively. Or, if the search would return less than M+N rows if it did not have a limit clause, then the first M rows are skipped and the remaining rows (if any) are returned. */
|
180
180
|
@property (nonatomic, assign, readwrite) NSUInteger offset;
|
181
181
|
/** * The limit clause is used to place an upper bound on the number of rows returned by a Search operation. */
|
182
182
|
@property (nonatomic, assign, readwrite) NSUInteger limit;
|
183
|
-
/** * limit a Search to a particular bag. */
|
184
|
-
@property (nonatomic, assign, readwrite) NSFNanoBag *bag;
|
185
183
|
|
186
184
|
/** @name Creating and Initializing a Search
|
187
185
|
*/
|
@@ -215,7 +213,7 @@
|
|
215
213
|
* @param theReturnType the type of object to be returned. Can be \link Globals::NSFReturnObjects NSFReturnObjects \endlink or \link Globals::NSFReturnKeys NSFReturnKeys \endlink.
|
216
214
|
* @param outError is used if an error occurs. May be NULL.
|
217
215
|
* @return An array is returned if: 1) the sort has been specified or 2) the return type is \link Globals::NSFReturnKeys NSFReturnKeys \endlink. Otherwise, a dictionary is returned.
|
218
|
-
* @note The sort descriptor will be ignored when
|
216
|
+
* @note The sort descriptor will be ignored when returning requesting NSFReturnKeys.
|
219
217
|
* @see \link searchObjectsAdded:date:returnType:error: - (id)searchObjectsAdded:(NSFDateMatchType)theDateMatch date:(NSDate *)theDate returnType:(NSFReturnType)theReturnType error:(out NSError **)outError \endlink
|
220
218
|
*/
|
221
219
|
|
@@ -227,7 +225,7 @@
|
|
227
225
|
* @param theReturnType the type of object to be returned. Can be \link Globals::NSFReturnObjects NSFReturnObjects \endlink or \link Globals::NSFReturnKeys NSFReturnKeys \endlink.
|
228
226
|
* @param outError is used if an error occurs. May be NULL.
|
229
227
|
* @return If theReturnType is \link Globals::NSFReturnObjects NSFReturnObjects \endlink, a dictionary is returned. Otherwise, an array is returned.
|
230
|
-
* @note The sort descriptor will be ignored when
|
228
|
+
* @note The sort descriptor will be ignored when returning requesting NSFReturnKeys.
|
231
229
|
* @see \link searchObjectsWithReturnType:error: - (id)searchObjectsWithReturnType:(NSFReturnType)theReturnType error:(out NSError **)outError \endlink
|
232
230
|
*/
|
233
231
|
|
@@ -75,7 +75,7 @@
|
|
75
75
|
@interface NSFNanoSortDescriptor : NSObject
|
76
76
|
|
77
77
|
/** * The property key to use when performing a comparison */
|
78
|
-
@property (nonatomic,
|
78
|
+
@property (nonatomic, readonly) NSString *attribute;
|
79
79
|
/** * The property to indicate whether the comparison should be performed in ascending mode */
|
80
80
|
@property (nonatomic, readonly) BOOL isAscending;
|
81
81
|
|
@@ -64,13 +64,6 @@
|
|
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
|
-
|
74
67
|
@section installation_sec Installation
|
75
68
|
|
76
69
|
Building NanoStore is very easy. Just follow these steps:
|
@@ -430,35 +423,6 @@
|
|
430
423
|
[sortByLastName release];
|
431
424
|
@endcode
|
432
425
|
|
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
|
-
|
462
426
|
@section performancetips_sec Performance Tips
|
463
427
|
|
464
428
|
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.
|
@@ -45,19 +45,23 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
45
45
|
|
46
46
|
#pragma mark -
|
47
47
|
|
48
|
-
@interface NSFNanoEngine ()
|
49
|
-
|
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
48
|
@implementation NSFNanoEngine
|
49
|
+
{
|
50
|
+
@protected
|
51
|
+
sqlite3 *sqlite;
|
52
|
+
NSString *path;
|
53
|
+
NSFCacheMethod cacheMethod;
|
54
|
+
|
55
|
+
/** \cond */
|
56
|
+
NSMutableDictionary *schema;
|
57
|
+
BOOL willCommitChangeSchema;
|
58
|
+
unsigned int busyTimeout;
|
59
|
+
/** \endcond */
|
60
|
+
}
|
61
|
+
|
62
|
+
@synthesize sqlite;
|
63
|
+
@synthesize path;
|
64
|
+
@synthesize cacheMethod;
|
61
65
|
|
62
66
|
#pragma mark -
|
63
67
|
|
@@ -83,7 +87,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
83
87
|
userInfo:nil]raise];
|
84
88
|
|
85
89
|
if ((self = [self init])) {
|
86
|
-
|
90
|
+
path = [thePath copy];
|
87
91
|
}
|
88
92
|
|
89
93
|
return self;
|
@@ -99,8 +103,8 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
99
103
|
- (id)init
|
100
104
|
{
|
101
105
|
if ((self = [super init])) {
|
102
|
-
|
103
|
-
|
106
|
+
path = nil;
|
107
|
+
schema = nil;
|
104
108
|
}
|
105
109
|
return self;
|
106
110
|
}
|
@@ -122,7 +126,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
122
126
|
NSFOrderedDictionary *values = [NSFOrderedDictionary new];
|
123
127
|
|
124
128
|
values[@"SQLite address"] = [NSString stringWithFormat:@"%p", self.sqlite];
|
125
|
-
values[@"Database path"] =
|
129
|
+
values[@"Database path"] = path;
|
126
130
|
values[@"Cache method"] = [self NSFP_cacheMethodToString];
|
127
131
|
|
128
132
|
return values;
|
@@ -144,7 +148,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
144
148
|
|
145
149
|
- (BOOL)openWithCacheMethod:(NSFCacheMethod)theCacheMethod useFastMode:(BOOL)useFastMode
|
146
150
|
{
|
147
|
-
int status = sqlite3_open_v2( [
|
151
|
+
int status = sqlite3_open_v2( [path UTF8String], &sqlite,
|
148
152
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_AUTOPROXY | SQLITE_OPEN_FULLMUTEX, NULL);
|
149
153
|
|
150
154
|
// Set NanoStoreEngine's page size to match the system current page size
|
@@ -162,7 +166,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
162
166
|
if ((SQLITE_OK != status) || (sqlite3_extended_result_codes(self.sqlite, 1) != SQLITE_OK))
|
163
167
|
return NO;
|
164
168
|
|
165
|
-
if ([[
|
169
|
+
if ([[path lowercaseString]isEqualToString:NSFMemoryDatabase] == YES) {
|
166
170
|
|
167
171
|
sqlite3_exec(self.sqlite, "PRAGMA fullfsync = OFF;", NULL, NULL, NULL);
|
168
172
|
sqlite3_exec(self.sqlite, "PRAGMA temp_store = MEMORY", NULL, NULL, NULL);
|
@@ -188,7 +192,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
188
192
|
}
|
189
193
|
|
190
194
|
// Save whether we want data to be fetched lazily
|
191
|
-
|
195
|
+
cacheMethod = theCacheMethod;
|
192
196
|
|
193
197
|
[self setBusyTimeout:250];
|
194
198
|
|
@@ -225,7 +229,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
225
229
|
}
|
226
230
|
|
227
231
|
int status = sqlite3_close(self.sqlite);
|
228
|
-
|
232
|
+
sqlite = NULL;
|
229
233
|
|
230
234
|
// Since we're operating with extended result code support, extract the bits
|
231
235
|
// and obtain the regular result code
|
@@ -248,7 +252,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
248
252
|
if (YES == [self isTransactionActive])
|
249
253
|
return NO;
|
250
254
|
|
251
|
-
|
255
|
+
willCommitChangeSchema = NO;
|
252
256
|
|
253
257
|
return [self beginDeferredTransaction];
|
254
258
|
}
|
@@ -258,7 +262,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
258
262
|
if (YES == [self isTransactionActive])
|
259
263
|
return NO;
|
260
264
|
|
261
|
-
|
265
|
+
willCommitChangeSchema = NO;
|
262
266
|
|
263
267
|
return [self NSFP_beginTransactionMode:@"BEGIN DEFERRED TRANSACTION;"];
|
264
268
|
}
|
@@ -266,19 +270,19 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
266
270
|
- (BOOL)commitTransaction
|
267
271
|
{
|
268
272
|
if (NO == [self isTransactionActive]) {
|
269
|
-
|
273
|
+
willCommitChangeSchema = NO;
|
270
274
|
return NO;
|
271
275
|
}
|
272
276
|
|
273
|
-
if (NO ==
|
277
|
+
if (NO == willCommitChangeSchema)
|
274
278
|
[self NSFP_uninstallCommitCallback];
|
275
279
|
|
276
280
|
BOOL success = (nil == [[self executeSQL:@"COMMIT TRANSACTION;"]error]);
|
277
281
|
|
278
|
-
if (NO ==
|
282
|
+
if (NO == willCommitChangeSchema)
|
279
283
|
[self NSFP_installCommitCallback];
|
280
284
|
|
281
|
-
|
285
|
+
willCommitChangeSchema = NO;
|
282
286
|
|
283
287
|
return success;
|
284
288
|
}
|
@@ -286,13 +290,13 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
286
290
|
- (BOOL)rollbackTransaction
|
287
291
|
{
|
288
292
|
if ([self isTransactionActive] == NO) {
|
289
|
-
|
293
|
+
willCommitChangeSchema = NO;
|
290
294
|
return NO;
|
291
295
|
}
|
292
296
|
|
293
297
|
BOOL success = (nil == [[self executeSQL:@"ROLLBACK TRANSACTION;"]error]);
|
294
298
|
|
295
|
-
|
299
|
+
willCommitChangeSchema = NO;
|
296
300
|
|
297
301
|
return success;
|
298
302
|
}
|
@@ -713,9 +717,14 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
713
717
|
theTimeout = 250;
|
714
718
|
}
|
715
719
|
|
716
|
-
|
720
|
+
busyTimeout = theTimeout;
|
717
721
|
|
718
|
-
sqlite3_busy_timeout(self.sqlite,
|
722
|
+
sqlite3_busy_timeout(self.sqlite, busyTimeout);
|
723
|
+
}
|
724
|
+
|
725
|
+
- (unsigned int)busyTimeout
|
726
|
+
{
|
727
|
+
return busyTimeout;
|
719
728
|
}
|
720
729
|
|
721
730
|
+ (NSInteger)systemPageSize
|
@@ -1069,7 +1078,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1069
1078
|
|
1070
1079
|
- (NSString *)NSFP_cacheMethodToString
|
1071
1080
|
{
|
1072
|
-
switch (
|
1081
|
+
switch (cacheMethod) {
|
1073
1082
|
case CacheAllData:
|
1074
1083
|
return @"Cache all data";
|
1075
1084
|
break;
|
@@ -1181,8 +1190,8 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1181
1190
|
NSString *datatype = nil;
|
1182
1191
|
|
1183
1192
|
// Check to see if the schema has been cached; take advantage of it if possible...
|
1184
|
-
if (nil !=
|
1185
|
-
datatype = [[
|
1193
|
+
if (nil != schema) {
|
1194
|
+
datatype = [[schema objectForKey:table]objectForKey:column];
|
1186
1195
|
if (nil == datatype) datatype = NSFStringFromNanoDataType(NSFNanoTypeUnknown);
|
1187
1196
|
} else {
|
1188
1197
|
NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT %@ from %@ WHERE %@ = '%@' AND %@ = '%@';", NSFP_DatatypeIdentifier, NSFP_SchemaTable, NSFP_TableIdentifier, table, NSFP_ColumnIdentifier, column];
|
@@ -1193,14 +1202,14 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1193
1202
|
|
1194
1203
|
if (nil == datatype) datatype = NSFStringFromNanoDataType(NSFNanoTypeUnknown);
|
1195
1204
|
|
1196
|
-
NSMutableDictionary *tempSchema = [
|
1205
|
+
NSMutableDictionary *tempSchema = [schema objectForKey:table];
|
1197
1206
|
if (nil != tempSchema)
|
1198
1207
|
tempSchema = [[NSMutableDictionary alloc]init];
|
1199
1208
|
else
|
1200
1209
|
;
|
1201
1210
|
|
1202
1211
|
[tempSchema setObject:datatype forKey:column];
|
1203
|
-
[
|
1212
|
+
[schema setObject:tempSchema forKey:table];
|
1204
1213
|
|
1205
1214
|
tempSchema = nil;
|
1206
1215
|
}
|
@@ -1504,8 +1513,8 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1504
1513
|
- (void)NSFP_rebuildDatatypeCache
|
1505
1514
|
{
|
1506
1515
|
// Cleanup
|
1507
|
-
|
1508
|
-
|
1516
|
+
schema = nil;
|
1517
|
+
schema = [[NSMutableDictionary alloc]init];
|
1509
1518
|
|
1510
1519
|
NSArray *tables = [self NSFP_flattenAllTables];
|
1511
1520
|
if ([tables count] == 0)
|
@@ -1526,7 +1535,7 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1526
1535
|
[tableDictionary setObject:[datatypes objectAtIndex:j] forKey:[columns objectAtIndex:j]];
|
1527
1536
|
}
|
1528
1537
|
|
1529
|
-
[
|
1538
|
+
[schema setObject:tableDictionary forKey:table];
|
1530
1539
|
}
|
1531
1540
|
}
|
1532
1541
|
|
@@ -1729,8 +1738,8 @@ static NSSet *__NSFPSharedNanoStoreEngineDatatypes = nil;
|
|
1729
1738
|
|
1730
1739
|
NSString *rowUIDDatatype = NSFStringFromNanoDataType(NSFNanoTypeRowUID);
|
1731
1740
|
|
1732
|
-
if (nil !=
|
1733
|
-
return [[[
|
1741
|
+
if (nil != schema)
|
1742
|
+
return [[[schema objectForKey:table]objectForKey:column]isEqualToString:rowUIDDatatype];
|
1734
1743
|
|
1735
1744
|
NSString *theSQLStatement = [NSString stringWithFormat:@"SELECT %@ FROM %@ WHERE %@ = '%@' AND %@ = '%@';", NSFP_DatatypeIdentifier, NSFP_SchemaTable, NSFP_TableIdentifier, table, NSFP_ColumnIdentifier, column];
|
1736
1745
|
NSFNanoResult* result = [self executeSQL:theSQLStatement];
|