nano-store 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/README.md +8 -4
  2. data/Rakefile +1 -1
  3. data/lib/nano_store.rb +2 -4
  4. data/lib/nano_store/version.rb +1 -1
  5. data/spec/model_spec.rb +14 -0
  6. data/spec/spec_helper.rb +4 -0
  7. data/vendor/Podfile.lock +4 -4
  8. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoGlobals.h +3 -1
  9. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoPredicate.h +5 -5
  10. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSearch.h +5 -3
  11. data/vendor/Pods/BuildHeaders/NanoStore/NSFNanoSortDescriptor.h +1 -1
  12. data/vendor/Pods/BuildHeaders/NanoStore/NanoStore.h +36 -0
  13. data/vendor/Pods/Documentation/NanoStore/docset-installed.txt +2 -2
  14. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Info.plist +3 -3
  15. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoBag.html +2 -2
  16. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoEngine.html +2 -2
  17. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoExpression.html +2 -2
  18. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoObject.html +2 -2
  19. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoPredicate.html +7 -7
  20. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoResult.html +2 -2
  21. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoSearch.html +66 -5
  22. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoSortDescriptor.html +3 -3
  23. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFNanoStore.html +2 -2
  24. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Classes/NSFOrderedDictionary.html +2 -2
  25. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/Protocols/NSFNanoObjectProtocol.html +2 -2
  26. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/css/styles.css +0 -0
  27. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/hierarchy.html +5 -5
  28. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Documents/index.html +5 -5
  29. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Nodes.xml +1 -1
  30. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens5.xml +6 -6
  31. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens7.xml +24 -2
  32. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/Tokens8.xml +2 -2
  33. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.dsidx +0 -0
  34. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.skidx +0 -0
  35. data/vendor/Pods/Documentation/NanoStore/docset/Contents/Resources/docSet.toc +0 -0
  36. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoBag.html +2 -2
  37. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoEngine.html +2 -2
  38. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoExpression.html +2 -2
  39. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoObject.html +2 -2
  40. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoPredicate.html +7 -7
  41. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoResult.html +2 -2
  42. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoSearch.html +66 -5
  43. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoSortDescriptor.html +3 -3
  44. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFNanoStore.html +2 -2
  45. data/vendor/Pods/Documentation/NanoStore/html/Classes/NSFOrderedDictionary.html +2 -2
  46. data/vendor/Pods/Documentation/NanoStore/html/Protocols/NSFNanoObjectProtocol.html +2 -2
  47. data/vendor/Pods/Documentation/NanoStore/html/css/styles.css +0 -0
  48. data/vendor/Pods/Documentation/NanoStore/html/hierarchy.html +5 -5
  49. data/vendor/Pods/Documentation/NanoStore/html/index.html +5 -5
  50. data/vendor/Pods/Headers/NanoStore/NSFNanoGlobals.h +3 -1
  51. data/vendor/Pods/Headers/NanoStore/NSFNanoPredicate.h +5 -5
  52. data/vendor/Pods/Headers/NanoStore/NSFNanoSearch.h +5 -3
  53. data/vendor/Pods/Headers/NanoStore/NSFNanoSortDescriptor.h +1 -1
  54. data/vendor/Pods/Headers/NanoStore/NanoStore.h +36 -0
  55. data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoEngine.m +40 -49
  56. data/vendor/Pods/NanoStore/Classes/Advanced/NSFNanoResult.m +42 -53
  57. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoBag.m +80 -89
  58. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoExpression.m +11 -13
  59. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.h +3 -1
  60. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoGlobals.m +1 -0
  61. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoObject.m +34 -29
  62. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.h +5 -5
  63. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoPredicate.m +43 -34
  64. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.h +5 -3
  65. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSearch.m +171 -97
  66. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.h +1 -1
  67. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoSortDescriptor.m +13 -12
  68. data/vendor/Pods/NanoStore/Classes/Public/NSFNanoStore.m +92 -86
  69. data/vendor/Pods/NanoStore/Classes/Public/NanoStore.h +36 -0
  70. data/vendor/Pods/Pods-resources.sh +8 -4
  71. data/vendor/Pods/Pods.bridgesupport +109 -101
  72. metadata +5 -5
@@ -31,13 +31,11 @@
31
31
  @implementation NSFNanoExpression
32
32
  {
33
33
  /** \cond */
34
- NSMutableArray *predicates;
35
- NSMutableArray *operators;
34
+ NSMutableArray *_predicates;
35
+ NSMutableArray *_operators;
36
36
  /** \endcond */
37
37
  }
38
38
 
39
- @synthesize predicates, operators;
40
-
41
39
  + (NSFNanoExpression*)expressionWithPredicate:(NSFNanoPredicate *)aPredicate
42
40
  {
43
41
  return [[self alloc]initWithPredicate:aPredicate];
@@ -52,10 +50,10 @@
52
50
  }
53
51
 
54
52
  if ((self = [super init])) {
55
- predicates = [NSMutableArray new];
56
- [predicates addObject:aPredicate];
57
- operators = [NSMutableArray new];
58
- [operators addObject:[NSNumber numberWithInt:NSFAnd]];
53
+ _predicates = [NSMutableArray new];
54
+ [_predicates addObject:aPredicate];
55
+ _operators = [NSMutableArray new];
56
+ [_operators addObject:[NSNumber numberWithInt:NSFAnd]];
59
57
  }
60
58
 
61
59
  return self;
@@ -75,8 +73,8 @@
75
73
  reason:[NSString stringWithFormat:@"*** -[%@ %@]: the predicate is nil.", [self class], NSStringFromSelector(_cmd)]
76
74
  userInfo:nil]raise];
77
75
 
78
- [predicates addObject:aPredicate];
79
- [operators addObject:[NSNumber numberWithInt:someOperator]];
76
+ [_predicates addObject:aPredicate];
77
+ [_operators addObject:[NSNumber numberWithInt:someOperator]];
80
78
  }
81
79
 
82
80
  - (NSString *)description
@@ -88,14 +86,14 @@
88
86
 
89
87
  - (NSArray *)arrayDescription
90
88
  {
91
- NSUInteger i, count = [predicates count];
89
+ NSUInteger i, count = [_predicates count];
92
90
  NSMutableArray *values = [NSMutableArray new];
93
91
 
94
92
  // We always have one predicate, so make sure add it
95
- [values addObject:[[predicates objectAtIndex:0]description]];
93
+ [values addObject:[[_predicates objectAtIndex:0]description]];
96
94
 
97
95
  for (i = 1; i < count; i++) {
98
- NSString *compound = [[NSString alloc]initWithFormat:@" %@ %@", ([[operators objectAtIndex:i]intValue] == NSFAnd) ? @"AND" : @"OR", [[predicates objectAtIndex:i]description]];
96
+ NSString *compound = [[NSString alloc]initWithFormat:@" %@ %@", ([[_operators objectAtIndex:i]intValue] == NSFAnd) ? @"AND" : @"OR", [[_predicates objectAtIndex:i]description]];
99
97
  [values addObject:compound];
100
98
  }
101
99
 
@@ -144,7 +144,9 @@ typedef enum {
144
144
  /** * Greater Ththanan */
145
145
  NSFGreaterThan,
146
146
  /** * Less than */
147
- NSFLessThan
147
+ NSFLessThan,
148
+ /** * Not Equal to from */
149
+ NSFNotEqualTo
148
150
  } NSFMatchType;
149
151
 
150
152
  /** * Column types for the Attributes table.
@@ -85,6 +85,7 @@ NSString * NSFStringFromMatchType (NSFMatchType aMatchType)
85
85
  case NSFInsensitiveEndsWith: value = @"Ends with (case insensitive)"; break;
86
86
  case NSFGreaterThan: value = @"Greater than"; break;
87
87
  case NSFLessThan: value = @"Less than"; break;
88
+ case NSFNotEqualTo: value = @"Not equal to"; break;
88
89
  }
89
90
 
90
91
  return value;
@@ -30,13 +30,18 @@
30
30
  #import "NSFNanoGlobals_Private.h"
31
31
  #import "NSFOrderedDictionary.h"
32
32
 
33
+ @interface NSFNanoObject ()
34
+ /** \cond */
35
+ @property (nonatomic, weak, readwrite) NSFNanoStore *store;
36
+ @property (nonatomic, copy, readwrite) NSString *key;
37
+ /** \endcond */
38
+ @end
39
+
33
40
  @implementation NSFNanoObject
34
41
  {
35
- NSMutableDictionary *info;
42
+ NSMutableDictionary *_info;
36
43
  }
37
44
 
38
- @synthesize info, key, originalClassString;
39
-
40
45
  + (NSFNanoObject *)nanoObject
41
46
  {
42
47
  return [[self alloc]initNanoObjectFromDictionaryRepresentation:nil forKey:nil store:nil];
@@ -69,13 +74,13 @@
69
74
  if ((self = [self init])) {
70
75
  // If we have supplied a key, honor it and overwrite the original one
71
76
  if (nil != aKey) {
72
- key = [aKey copy];
77
+ _key = aKey;
73
78
  }
74
79
 
75
80
  // Keep the dictionary if needed
76
81
  if (nil != aDictionary) {
77
- info = [NSMutableDictionary new];
78
- [info addEntriesFromDictionary:aDictionary];
82
+ _info = [NSMutableDictionary new];
83
+ [_info addEntriesFromDictionary:aDictionary];
79
84
  }
80
85
 
81
86
  _store = aStore;
@@ -99,10 +104,10 @@
99
104
  NSFOrderedDictionary *values = [NSFOrderedDictionary new];
100
105
 
101
106
  values[@"NanoObject address"] = [NSString stringWithFormat:@"%p", self];
102
- values[@"Original class"] = (nil != originalClassString) ? originalClassString : NSStringFromClass ([self class]);
103
- values[@"Key"] = key;
104
- values[@"Property count"] = @([info count]);
105
- values[@"Contents"] = info;
107
+ values[@"Original class"] = (nil != _originalClassString) ? _originalClassString : NSStringFromClass ([self class]);
108
+ values[@"Key"] = _key;
109
+ values[@"Property count"] = @([_info count]);
110
+ values[@"Contents"] = _info;
106
111
 
107
112
  return values;
108
113
  }
@@ -120,41 +125,41 @@
120
125
  - (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary
121
126
  {
122
127
  // Allocate the dictionary if needed
123
- if (nil == info) {
124
- info = [NSMutableDictionary new];
128
+ if (nil == _info) {
129
+ _info = [NSMutableDictionary new];
125
130
  }
126
131
 
127
- [info addEntriesFromDictionary:otherDictionary];
132
+ [_info addEntriesFromDictionary:otherDictionary];
128
133
  }
129
134
 
130
135
  - (void)setObject:(id)anObject forKey:(NSString *)aKey
131
136
  {
132
137
  // Allocate the dictionary if needed
133
- if (nil == info) {
134
- info = [NSMutableDictionary new];
138
+ if (nil == _info) {
139
+ _info = [NSMutableDictionary new];
135
140
  }
136
141
 
137
- [info setObject:anObject forKey:aKey];
142
+ [_info setObject:anObject forKey:aKey];
138
143
  }
139
144
 
140
145
  - (id)objectForKey:(NSString *)aKey
141
146
  {
142
- return [info objectForKey:aKey];
147
+ return [_info objectForKey:aKey];
143
148
  }
144
149
 
145
150
  - (void)removeObjectForKey:(NSString *)aKey
146
151
  {
147
- [info removeObjectForKey:aKey];
152
+ [_info removeObjectForKey:aKey];
148
153
  }
149
154
 
150
155
  - (void)removeAllObjects
151
156
  {
152
- [info removeAllObjects];
157
+ [_info removeAllObjects];
153
158
  }
154
159
 
155
160
  - (void)removeObjectsForKeys:(NSArray *)keyArray
156
161
  {
157
- [info removeObjectsForKeys:keyArray];
162
+ [_info removeObjectsForKeys:keyArray];
158
163
  }
159
164
 
160
165
  - (BOOL)isEqualToNanoObject:(NSFNanoObject *)otherNanoObject
@@ -165,14 +170,14 @@
165
170
 
166
171
  BOOL success = YES;
167
172
 
168
- if (originalClassString != otherNanoObject.originalClassString) {
169
- if (NO == [originalClassString isEqualToString:otherNanoObject.originalClassString]) {
173
+ if (_originalClassString != otherNanoObject.originalClassString) {
174
+ if (NO == [_originalClassString isEqualToString:otherNanoObject.originalClassString]) {
170
175
  success = NO;
171
176
  }
172
177
  }
173
178
 
174
179
  if (YES == success) {
175
- success = [info isEqualToDictionary:otherNanoObject.info];
180
+ success = [_info isEqualToDictionary:otherNanoObject.info];
176
181
  }
177
182
 
178
183
  return success;
@@ -195,9 +200,9 @@
195
200
  - (id)init
196
201
  {
197
202
  if ((self = [super init])) {
198
- key = [[NSFNanoEngine stringWithUUID]copy];
199
- info = nil;
200
- originalClassString = nil;
203
+ _key = [NSFNanoEngine stringWithUUID];
204
+ _info = nil;
205
+ _originalClassString = nil;
201
206
  _store = nil;
202
207
  }
203
208
 
@@ -225,7 +230,7 @@
225
230
 
226
231
  - (id)rootObject
227
232
  {
228
- return info;
233
+ return _info;
229
234
  }
230
235
 
231
236
  #pragma mark -
@@ -234,8 +239,8 @@
234
239
 
235
240
  - (void)_setOriginalClassString:(NSString *)theClassString
236
241
  {
237
- if (originalClassString != theClassString) {
238
- originalClassString = theClassString;
242
+ if (_originalClassString != theClassString) {
243
+ _originalClassString = theClassString;
239
244
  }
240
245
  }
241
246
 
@@ -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, copy, readonly) NSString *value;
80
+ @property (nonatomic, readonly) id 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 is the value.
90
+ * @param theValue can be an NSString or [NSNull null]
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:(NSString *)theValue;
95
+ + (NSFNanoPredicate*)predicateWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(id)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 is the value.
100
+ * @param theValue can be an NSString or [NSNull null]
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:(NSString *)theValue;
105
+ - (id)initWithColumn:(NSFTableColumnType)theType matching:(NSFMatchType)theMatch value:(id)theValue;
106
106
 
107
107
  //@}
108
108
 
@@ -28,35 +28,36 @@
28
28
  #import "NanoStore_Private.h"
29
29
  #import "NSFOrderedDictionary.h"
30
30
 
31
- @implementation NSFNanoPredicate
31
+ @interface NSFNanoPredicate ()
32
+
33
+ /** \cond */
34
+ @property (nonatomic, assign, readwrite) NSFTableColumnType column;
35
+ @property (nonatomic, assign, readwrite) NSFMatchType match;
36
+ @property (nonatomic, readwrite) id value;
37
+ /** \endcond */
32
38
 
33
- @synthesize column, match, value;
39
+ @end
40
+
41
+ @implementation NSFNanoPredicate
34
42
 
35
43
  // ----------------------------------------------
36
44
  // Initialization / Cleanup
37
45
  // ----------------------------------------------
38
46
 
39
- + (NSFNanoPredicate*)predicateWithColumn:(NSFTableColumnType)type matching:(NSFMatchType)matching value:(NSString *)aValue
47
+ + (NSFNanoPredicate*)predicateWithColumn:(NSFTableColumnType)type matching:(NSFMatchType)matching value:(id)aValue
40
48
  {
41
- if (nil == aValue)
42
- [[NSException exceptionWithName:NSFUnexpectedParameterException
43
- reason:[NSString stringWithFormat:@"*** -[%@ %@]: value is nil.", [self class], NSStringFromSelector(_cmd)]
44
- userInfo:nil]raise];
45
-
46
49
  return [[self alloc]initWithColumn:type matching:matching value:aValue];
47
50
  }
48
51
 
49
- - (id)initWithColumn:(NSFTableColumnType)type matching:(NSFMatchType)matching value:(NSString *)aValue
52
+ - (id)initWithColumn:(NSFTableColumnType)type matching:(NSFMatchType)matching value:(id)aValue
50
53
  {
51
- if (nil == aValue)
52
- [[NSException exceptionWithName:NSFUnexpectedParameterException
53
- reason:[NSString stringWithFormat:@"*** -[%@ %@]: value is nil.", [self class], NSStringFromSelector(_cmd)]
54
- userInfo:nil]raise];
55
-
54
+ NSAssert(nil != aValue, @"*** -[%@ %@]: value is nil.", [self class], NSStringFromSelector(_cmd));
55
+ NSAssert([aValue isKindOfClass:[NSString class]] || [aValue isKindOfClass:[NSNull class]], @"*** -[%@ %@]: value must be of type NSString or NSNull.", [self class], NSStringFromSelector(_cmd));
56
+
56
57
  if ((self = [super init])) {
57
- column = type;
58
- match = matching;
59
- value = aValue;
58
+ _column = type;
59
+ _match = matching;
60
+ _value = aValue;
60
61
  }
61
62
 
62
63
  return self;
@@ -75,7 +76,7 @@
75
76
  NSMutableString *mutatedString = nil;
76
77
  NSInteger mutatedStringLength = 0;
77
78
 
78
- switch (column) {
79
+ switch (_column) {
79
80
  case NSFKeyColumn:
80
81
  columnValue = NSFKey;
81
82
  break;
@@ -88,44 +89,52 @@
88
89
  }
89
90
 
90
91
  // Make sure we escape quotes if present and the value is a string
91
- value = [value stringByReplacingOccurrencesOfString:@"'" withString:@"''"];
92
+ if (YES == [_value isKindOfClass:[NSString class]]) {
93
+ _value = [_value stringByReplacingOccurrencesOfString:@"'" withString:@"''"];
94
+ } else {
95
+ _value = NSFStringFromNanoDataType(NSFNanoTypeNULL);
96
+ columnValue = NSFDatatype;
97
+ }
92
98
 
93
- switch (match) {
99
+ switch (_match) {
94
100
  case NSFEqualTo:
95
- [values addObject:[NSString stringWithFormat:@"%@ = '%@'", columnValue, value]];
101
+ [values addObject:[NSString stringWithFormat:@"%@ = '%@'", columnValue, _value]];
96
102
  break;
97
103
  case NSFBeginsWith:
98
- mutatedString = [NSMutableString stringWithString:value];
99
- mutatedStringLength = [value length];
104
+ mutatedString = [NSMutableString stringWithString:_value];
105
+ mutatedStringLength = [_value length];
100
106
  [mutatedString replaceCharactersInRange:NSMakeRange(mutatedStringLength - 1, 1) withString:[NSString stringWithFormat:@"%c", [mutatedString characterAtIndex:mutatedStringLength - 1]+1]];
101
- [values addObject:[NSString stringWithFormat:@"(%@ >= '%@' AND %@ < '%@')", columnValue, value, columnValue, mutatedString]];
107
+ [values addObject:[NSString stringWithFormat:@"(%@ >= '%@' AND %@ < '%@')", columnValue, _value, columnValue, mutatedString]];
102
108
  break;
103
109
  case NSFContains:
104
- [values addObject:[NSString stringWithFormat:@"%@ GLOB '*%@*'", columnValue, value]];
110
+ [values addObject:[NSString stringWithFormat:@"%@ GLOB '*%@*'", columnValue, _value]];
105
111
  break;
106
112
  case NSFEndsWith:
107
- [values addObject:[NSString stringWithFormat:@"%@ GLOB '*%@'", columnValue, value]];
113
+ [values addObject:[NSString stringWithFormat:@"%@ GLOB '*%@'", columnValue, _value]];
108
114
  break;
109
115
  case NSFInsensitiveEqualTo:
110
- [values addObject:[NSString stringWithFormat:@"upper(%@) = '%@'", columnValue, [value uppercaseString]]];
116
+ [values addObject:[NSString stringWithFormat:@"upper(%@) = '%@'", columnValue, [_value uppercaseString]]];
111
117
  break;
112
118
  case NSFInsensitiveBeginsWith:
113
- mutatedString = [NSMutableString stringWithString:value];
114
- mutatedStringLength = [value length];
119
+ mutatedString = [NSMutableString stringWithString:_value];
120
+ mutatedStringLength = [_value length];
115
121
  [mutatedString replaceCharactersInRange:NSMakeRange(mutatedStringLength - 1, 1) withString:[NSString stringWithFormat:@"%c", [mutatedString characterAtIndex:mutatedStringLength - 1]+1]];
116
- [values addObject:[NSString stringWithFormat:@"(upper(%@) >= '%@' AND upper(%@) < '%@')", columnValue, [value uppercaseString], columnValue, [mutatedString uppercaseString]]];
122
+ [values addObject:[NSString stringWithFormat:@"(upper(%@) >= '%@' AND upper(%@) < '%@')", columnValue, [_value uppercaseString], columnValue, [mutatedString uppercaseString]]];
117
123
  break;
118
124
  case NSFInsensitiveContains:
119
- [values addObject:[NSString stringWithFormat:@"%@ LIKE '%@%@%@'", columnValue, @"%", value, @"%"]];
125
+ [values addObject:[NSString stringWithFormat:@"%@ LIKE '%@%@%@'", columnValue, @"%", _value, @"%"]];
120
126
  break;
121
127
  case NSFInsensitiveEndsWith:
122
- [values addObject:[NSString stringWithFormat:@"%@ LIKE '%@%@'", columnValue, @"%", value]];
128
+ [values addObject:[NSString stringWithFormat:@"%@ LIKE '%@%@'", columnValue, @"%", _value]];
123
129
  break;
124
130
  case NSFGreaterThan:
125
- [values addObject:[NSString stringWithFormat:@"%@ > '%@'", columnValue, value]];
131
+ [values addObject:[NSString stringWithFormat:@"%@ > '%@'", columnValue, _value]];
126
132
  break;
127
133
  case NSFLessThan:
128
- [values addObject:[NSString stringWithFormat:@"%@ < '%@'", columnValue, value]];
134
+ [values addObject:[NSString stringWithFormat:@"%@ < '%@'", columnValue, _value]];
135
+ break;
136
+ case NSFNotEqualTo:
137
+ [values addObject:[NSString stringWithFormat:@"%@ <> '%@'", columnValue, _value]];
129
138
  break;
130
139
  }
131
140
 
@@ -175,11 +175,13 @@
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, strong, readwrite) NSString *filterClass;
178
+ @property (nonatomic, copy, 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;
183
185
 
184
186
  /** @name Creating and Initializing a Search
185
187
  */
@@ -213,7 +215,7 @@
213
215
  * @param theReturnType the type of object to be returned. Can be \link Globals::NSFReturnObjects NSFReturnObjects \endlink or \link Globals::NSFReturnKeys NSFReturnKeys \endlink.
214
216
  * @param outError is used if an error occurs. May be NULL.
215
217
  * @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.
216
- * @note The sort descriptor will be ignored when returning requesting NSFReturnKeys.
218
+ * @note The sort descriptor will be ignored when the return type is NSFReturnKeys.
217
219
  * @see \link searchObjectsAdded:date:returnType:error: - (id)searchObjectsAdded:(NSFDateMatchType)theDateMatch date:(NSDate *)theDate returnType:(NSFReturnType)theReturnType error:(out NSError **)outError \endlink
218
220
  */
219
221
 
@@ -225,7 +227,7 @@
225
227
  * @param theReturnType the type of object to be returned. Can be \link Globals::NSFReturnObjects NSFReturnObjects \endlink or \link Globals::NSFReturnKeys NSFReturnKeys \endlink.
226
228
  * @param outError is used if an error occurs. May be NULL.
227
229
  * @return If theReturnType is \link Globals::NSFReturnObjects NSFReturnObjects \endlink, a dictionary is returned. Otherwise, an array is returned.
228
- * @note The sort descriptor will be ignored when returning requesting NSFReturnKeys.
230
+ * @note The sort descriptor will be ignored when the return type is NSFReturnKeys.
229
231
  * @see \link searchObjectsWithReturnType:error: - (id)searchObjectsWithReturnType:(NSFReturnType)theReturnType error:(out NSError **)outError \endlink
230
232
  */
231
233
 
@@ -29,16 +29,15 @@
29
29
  #import "NSFNanoSearch_Private.h"
30
30
  #import "NSFNanoExpression_Private.h"
31
31
 
32
- @implementation NSFNanoSearch
33
- {
34
- /** \cond */
35
- @protected
36
- NSFReturnType returnedObjectType;
37
- /** \endcond */
38
- }
32
+ @interface NSFNanoSearch ()
39
33
 
34
+ /** \cond */
35
+ @property (nonatomic, copy, readwrite) NSString *sql;
36
+ @property (nonatomic) NSFReturnType returnedObjectType;
37
+ /** \endcond */
38
+ @end
40
39
 
41
- @synthesize nanoStore, attributesToBeReturned, key, attribute, value, match, expressions, groupValues, sql, sort, filterClass, offset, limit;
40
+ @implementation NSFNanoSearch
42
41
 
43
42
  // ----------------------------------------------
44
43
  // Initialization / Cleanup
@@ -58,7 +57,7 @@
58
57
  }
59
58
 
60
59
  if ((self = [self init])) {
61
- nanoStore = store;
60
+ _nanoStore = store;
62
61
  [self reset];
63
62
  }
64
63
 
@@ -78,10 +77,10 @@
78
77
 
79
78
  - (NSString *)sql
80
79
  {
81
- if (nil == sql)
80
+ if (nil == _sql)
82
81
  return [self _preparedSQL];
83
82
 
84
- return sql;
83
+ return _sql;
85
84
  }
86
85
 
87
86
  #pragma mark -
@@ -105,8 +104,8 @@
105
104
  [self reset];
106
105
  self.sort = savedSort;
107
106
 
108
- returnedObjectType = theReturnType;
109
- sql = [theSQLStatement copy];
107
+ _returnedObjectType = theReturnType;
108
+ _sql = theSQLStatement;
110
109
 
111
110
  NSDictionary *results = [self _retrieveDataWithError:outError];
112
111
 
@@ -130,9 +129,9 @@
130
129
  // Make sure we don't have any lingering parameters that could mess with the results...
131
130
  [self reset];
132
131
 
133
- sql = theSQLStatement;
132
+ _sql = theSQLStatement;
134
133
 
135
- return [nanoStore _executeSQL:theSQLStatement];
134
+ return [_nanoStore _executeSQL:theSQLStatement];
136
135
  }
137
136
 
138
137
  - (NSFNanoResult *)explainSQL:(NSString *)theSQLStatement
@@ -149,32 +148,32 @@
149
148
  userInfo:nil]raise];
150
149
  }
151
150
 
152
- return [nanoStore _executeSQL:[NSString stringWithFormat:@"EXPLAIN %@", theSQLStatement]];
151
+ return [_nanoStore _executeSQL:[NSString stringWithFormat:@"EXPLAIN %@", theSQLStatement]];
153
152
  }
154
153
 
155
154
  - (void)reset
156
155
  {
157
- attributesToBeReturned= nil;
158
- key = nil;
159
- attribute = nil;
160
- value = nil;
161
- match = NSFContains;
162
- groupValues = NO;
163
- sql = nil;
164
- sort = nil;
165
- offset = 0;
166
- limit = 0;
167
- returnedObjectType = NSFReturnObjects;
156
+ _attributesToBeReturned = nil;
157
+ _key = nil;
158
+ _attribute = nil;
159
+ _value = nil;
160
+ _match = NSFContains;
161
+ _groupValues = NO;
162
+ _sql = nil;
163
+ _sort = nil;
164
+ _offset = 0;
165
+ _limit = 0;
166
+ _returnedObjectType = NSFReturnObjects;
168
167
  }
169
168
 
170
169
  #pragma mark -
171
170
 
172
171
  - (id)searchObjectsWithReturnType:(NSFReturnType)theReturnType error:(out NSError **)outError
173
172
  {
174
- returnedObjectType = theReturnType;
173
+ _returnedObjectType = theReturnType;
175
174
 
176
175
  // Make sure we don't have a SQL statement around...
177
- sql = nil;
176
+ _sql = nil;
178
177
 
179
178
  id results = [self _retrieveDataWithError:outError];
180
179
 
@@ -183,10 +182,10 @@
183
182
 
184
183
  - (id)searchObjectsAdded:(NSFDateMatchType)theDateMatch date:(NSDate *)theDate returnType:(NSFReturnType)theReturnType error:(out NSError **)outError
185
184
  {
186
- returnedObjectType = theReturnType;
185
+ _returnedObjectType = theReturnType;
187
186
 
188
187
  // Make sure we don't have a SQL statement around...
189
- sql = nil;
188
+ _sql = nil;
190
189
 
191
190
  id results = [self _retrieveDataAdded:theDateMatch calendarDate:theDate error:outError];
192
191
 
@@ -199,11 +198,11 @@
199
198
 
200
199
  - (NSNumber *)aggregateOperation:(NSFAggregateFunctionType)theFunctionType onAttribute:(NSString *)theAttribute
201
200
  {
202
- NSFReturnType savedObjectTypeReturned = returnedObjectType;
203
- returnedObjectType = NSFReturnKeys;
201
+ NSFReturnType savedObjectTypeReturned = _returnedObjectType;
202
+ _returnedObjectType = NSFReturnKeys;
204
203
 
205
- NSString *savedSQL = sql;
206
- sql = nil;
204
+ NSString *savedSQL = _sql;
205
+ _sql = nil;
207
206
 
208
207
  NSString *theSearchSQLStatement = [self sql];
209
208
  NSMutableString *theAggregatedSQLStatement = [NSMutableString new];
@@ -232,10 +231,10 @@
232
231
  break;
233
232
  }
234
233
 
235
- NSFNanoResult *result = [nanoStore _executeSQL:theAggregatedSQLStatement];
234
+ NSFNanoResult *result = [_nanoStore _executeSQL:theAggregatedSQLStatement];
236
235
 
237
- returnedObjectType = savedObjectTypeReturned;
238
- sql = savedSQL;
236
+ _returnedObjectType = savedObjectTypeReturned;
237
+ _sql = savedSQL;
239
238
 
240
239
  return [NSNumber numberWithFloat:[[result firstValue]floatValue]];
241
240
  }
@@ -248,13 +247,13 @@
248
247
 
249
248
  - (NSDictionary *)_retrieveDataWithError:(out NSError **)outError
250
249
  {
251
- if (YES == [nanoStore isClosed]) {
250
+ if (YES == [_nanoStore isClosed]) {
252
251
  return nil;
253
252
  }
254
253
 
255
254
  NSMutableDictionary *searchResults = [NSMutableDictionary dictionary];
256
255
 
257
- NSString *aSQLQuery = sql;
256
+ NSString *aSQLQuery = _sql;
258
257
 
259
258
  if (nil != aSQLQuery) {
260
259
  // We are going to check whether the user has specified the proper columns based on the search type selected.
@@ -263,7 +262,7 @@
263
262
  // We basically honor the specified query but replace the columns with the expected ones per returned type.
264
263
 
265
264
  NSString *subStatement = [aSQLQuery substringFromIndex:[aSQLQuery rangeOfString:@"FROM" options:NSCaseInsensitiveSearch].location];
266
- NSFReturnType returnType = returnedObjectType;
265
+ NSFReturnType returnType = _returnedObjectType;
267
266
  switch (returnType) {
268
267
  case NSFReturnKeys:
269
268
  aSQLQuery = [NSString stringWithFormat:@"SELECT NSFKey %@", subStatement];
@@ -278,7 +277,7 @@
278
277
 
279
278
  _NSFLog(@"_dataWithKey SQL query: %@", aSQLQuery);
280
279
 
281
- sqlite3 *sqliteStore = [[nanoStore nanoStoreEngine]sqlite];
280
+ sqlite3 *sqliteStore = [[_nanoStore nanoStoreEngine]sqlite];
282
281
  sqlite3_stmt *theSQLiteStatement = NULL;
283
282
 
284
283
  int status = sqlite3_prepare_v2 (sqliteStore, [aSQLQuery UTF8String], -1, &theSQLiteStatement, NULL );
@@ -286,7 +285,7 @@
286
285
  status = [NSFNanoEngine NSFP_stripBitsFromExtendedResultCode:status];
287
286
 
288
287
  if (SQLITE_OK == status) {
289
- switch (returnedObjectType) {
288
+ switch (_returnedObjectType) {
290
289
  case NSFReturnKeys:
291
290
  while (SQLITE_ROW == sqlite3_step (theSQLiteStatement)) {
292
291
  // Sanity check: some queries return NULL, which would cause a crash below.
@@ -322,7 +321,7 @@
322
321
  continue;
323
322
  }
324
323
 
325
- if ([attributesToBeReturned count] == 0) {
324
+ if ([_attributesToBeReturned count] == 0) {
326
325
  // Will be released below...
327
326
  } else {
328
327
  // Since we want a subset of the attributes, we need to traverse
@@ -332,7 +331,7 @@
332
331
 
333
332
  NSMutableDictionary *subset = [NSMutableDictionary new];
334
333
 
335
- for (NSString *attributeValue in attributesToBeReturned) {
334
+ for (NSString *attributeValue in _attributesToBeReturned) {
336
335
  id theValue = [info valueForKeyPath:attributeValue];
337
336
  if (nil != theValue) {
338
337
  if (NSNotFound == [attributeValue rangeOfString:@"."].location) {
@@ -359,7 +358,7 @@
359
358
  saveOriginalClassReference = YES;
360
359
  }
361
360
 
362
- id nanoObject = [[storedObjectClass alloc]initNanoObjectFromDictionaryRepresentation:info forKey:keyValue store:nanoStore];
361
+ id nanoObject = [[storedObjectClass alloc]initNanoObjectFromDictionaryRepresentation:info forKey:keyValue store:_nanoStore];
363
362
 
364
363
  // If this process does not have knowledge of the original class as was saved in the store, keep a reference
365
364
  // so that we can later on restore the object properly (otherwise it would be stored as a NanoObject.)
@@ -391,7 +390,7 @@
391
390
 
392
391
  - (NSDictionary *)_retrieveDataAdded:(NSFDateMatchType)aDateMatch calendarDate:(NSDate *)aDate error:(out NSError **)outError
393
392
  {
394
- if ([nanoStore isClosed] == YES) {
393
+ if ([_nanoStore isClosed] == YES) {
395
394
  return nil;
396
395
  }
397
396
 
@@ -422,12 +421,12 @@
422
421
  break;
423
422
  }
424
423
 
425
- NSFNanoResult *result = [nanoStore _executeSQL:theSQLStatement];
424
+ NSFNanoResult *result = [_nanoStore _executeSQL:theSQLStatement];
426
425
 
427
426
  NSMutableDictionary *searchResults = [NSMutableDictionary dictionaryWithCapacity:result.numberOfRows];
428
427
 
429
428
  if (result.numberOfRows > 0) {
430
- if (NSFReturnKeys == returnedObjectType) {
429
+ if (NSFReturnKeys == _returnedObjectType) {
431
430
  NSArray *resultsKeys = [result valuesForColumn:[NSString stringWithFormat:@"%@.%@", NSFKeys, NSFKey]];
432
431
  for (NSString *resultKey in resultsKeys)
433
432
  [searchResults setObject:[NSNull null] forKey:resultKey];
@@ -452,7 +451,7 @@
452
451
  saveOriginalClassReference = YES;
453
452
  }
454
453
 
455
- id nanoObject = [[storedObjectClass alloc]initNanoObjectFromDictionaryRepresentation:info forKey:keyValue store:nanoStore];
454
+ id nanoObject = [[storedObjectClass alloc]initNanoObjectFromDictionaryRepresentation:info forKey:keyValue store:_nanoStore];
456
455
 
457
456
  // If this process does not have knowledge of the original class as was saved in the store, keep a reference
458
457
  // so that we can later on restore the object properly (otherwise it would be stored as a NanoObject.)
@@ -474,20 +473,20 @@
474
473
  {
475
474
  NSString *aSQLQuery = nil;
476
475
 
477
- if (nil == expressions) {
478
- aSQLQuery = [self _prepareSQLQueryStringWithKey:key attribute:attribute value:value matching:match];
476
+ if (nil == _expressions) {
477
+ aSQLQuery = [self _prepareSQLQueryStringWithKey:_key attribute:_attribute value:_value matching:_match];
479
478
  } else {
480
- aSQLQuery = [self _prepareSQLQueryStringWithExpressions:expressions];
479
+ aSQLQuery = [self _prepareSQLQueryStringWithExpressions:_expressions];
481
480
  }
482
481
 
483
482
  // Add the limit clause if required
484
- if (limit > 0) {
485
- aSQLQuery = [NSString stringWithFormat:@"%@ LIMIT %li", aSQLQuery, limit];
483
+ if (_limit > 0) {
484
+ aSQLQuery = [NSString stringWithFormat:@"%@ LIMIT %li", aSQLQuery, _limit];
486
485
  }
487
486
 
488
487
  // Add the offset clause if required
489
- if (offset > 0) {
490
- aSQLQuery = [NSString stringWithFormat:@"%@ OFFSET %li", aSQLQuery, offset];
488
+ if (_offset > 0) {
489
+ aSQLQuery = [NSString stringWithFormat:@"%@ OFFSET %li", aSQLQuery, _offset];
491
490
  }
492
491
 
493
492
  return aSQLQuery;
@@ -503,9 +502,9 @@
503
502
  aValue = [aValue stringByReplacingOccurrencesOfString:@"'" withString:@"''"];
504
503
  }
505
504
 
506
- if (nil != attributesToBeReturned) {
505
+ if (nil != _attributesToBeReturned) {
507
506
  // Prepare the list of attributes we need to gather. Include NSFKEY as well.
508
- NSMutableSet *set = [[NSMutableSet alloc]initWithArray:attributesToBeReturned];
507
+ NSMutableSet *set = [[NSMutableSet alloc]initWithArray:_attributesToBeReturned];
509
508
  NSArray *objects = [set allObjects];
510
509
  NSMutableArray *quotedObjects = [NSMutableArray new];
511
510
  for (NSString *object in objects) {
@@ -515,7 +514,7 @@
515
514
  attributes = [quotedObjects componentsJoinedByString:@","];
516
515
  }
517
516
 
518
- NSFReturnType returnType = returnedObjectType;
517
+ NSFReturnType returnType = _returnedObjectType;
519
518
 
520
519
  if ((nil == aKey) && (nil == anAttribute) && (nil == aValue)) {
521
520
  switch (returnType) {
@@ -529,7 +528,7 @@
529
528
  } else {
530
529
  switch (returnType) {
531
530
  case NSFReturnKeys:
532
- if (NO == groupValues) {
531
+ if (NO == _groupValues) {
533
532
  theSQLStatement = [NSMutableString stringWithString:@"SELECT DISTINCT (NSFKEY) FROM NSFValues WHERE "];
534
533
  } else {
535
534
  theSQLStatement = [NSMutableString stringWithString:@"SELECT NSFKEY FROM NSFValues WHERE "];
@@ -570,11 +569,15 @@
570
569
  segment = [NSFNanoSearch _querySegmentForColumn:NSFAttribute value:anAttribute matching:NSFEqualTo];
571
570
  [theSQLStatement appendString:segment];
572
571
  [theSQLStatement appendString:@" AND "];
573
- segment = [NSFNanoSearch _querySegmentForColumn:NSFValue value:aValue matching:NSFEqualTo];
572
+ segment = [NSFNanoSearch _querySegmentForColumn:NSFValue value:aValue matching:aMatch];
574
573
  }
575
574
  }
576
575
 
577
576
  [theSQLStatement appendString:segment];
577
+ if (self.bag != nil) {
578
+ NSString *selectInABag = [NSString stringWithFormat:@" AND NSFKey IN (SELECT NSFValue FROM NSFVALUES WHERE NSFKey == '%@' AND NSFAttribute == '%@')",self.bag.key,NSF_Private_NSFNanoBag_NSFObjectKeys];
579
+ [theSQLStatement appendString:selectInABag];
580
+ }
578
581
  } else {
579
582
  if (nil != aValue) {
580
583
  if (YES == querySegmentWasAdded)
@@ -584,11 +587,11 @@
584
587
  }
585
588
  }
586
589
 
587
- if ((limit > 0) || (offset > 0)) {
590
+ if ((_limit > 0) || (_offset > 0)) {
588
591
  [theSQLStatement appendString:@" ORDER BY ROWID"];
589
592
  }
590
593
 
591
- if (YES == groupValues) {
594
+ if (YES == _groupValues) {
592
595
  [theSQLStatement appendString:@" GROUP BY NSFValue"];
593
596
  }
594
597
 
@@ -612,7 +615,7 @@
612
615
  NSUInteger i, count = [someExpressions count];
613
616
  NSMutableArray *sqlComponents = [NSMutableArray new];
614
617
  NSMutableString *parentheses = [NSMutableString new];
615
- NSFReturnType returnType = returnedObjectType;
618
+ NSFReturnType returnType = _returnedObjectType;
616
619
 
617
620
  if (count == 0) {
618
621
  if (NSFReturnObjects == returnType) {
@@ -733,6 +736,10 @@
733
736
  value = [[NSMutableString alloc]initWithFormat:@"%@ < '%@'", aColumn, aValue];
734
737
  [segment appendString:value];
735
738
  break;
739
+ case NSFNotEqualTo:
740
+ value = [[NSMutableString alloc]initWithFormat:@"%@ <> '%@'", aColumn, aValue];
741
+ [segment appendString:value];
742
+ break;
736
743
  }
737
744
  } else if (YES == [aValue isKindOfClass:[NSArray class]]) {
738
745
  // Quote the parameters
@@ -750,6 +757,19 @@
750
757
  [segment appendString:value];
751
758
 
752
759
  // Free allocated resources
760
+ } else if (YES == [aValue isKindOfClass:[NSNull class]]){
761
+ switch (match) {
762
+ case NSFEqualTo:
763
+ value = [[NSMutableString alloc]initWithFormat:@"%@ IS NULL", aColumn];
764
+ [segment appendString:value];
765
+ break;
766
+ case NSFNotEqualTo:
767
+ value = [[NSMutableString alloc]initWithFormat:@"%@ IS NOT NULL", aColumn];
768
+ [segment appendString:value];
769
+ break;
770
+ default:
771
+ break;
772
+ }
753
773
  }
754
774
 
755
775
  return segment;
@@ -762,51 +782,56 @@
762
782
 
763
783
  if ((YES == [aValue isKindOfClass:[NSString class]]) || (nil == aValue)) {
764
784
  if (nil == aValue) {
765
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@') OR (%@ GLOB '%@.*') OR (%@ GLOB '*.%@.*') OR (%@ GLOB '*.%@')", NSFAttribute, anAttributeValue, NSFAttribute, anAttributeValue, NSFAttribute, anAttributeValue, NSFAttribute, anAttributeValue];
785
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@') OR (%@ GLOB '%@.*') OR (%@ GLOB '*.%@.*') OR (%@ GLOB '*.%@'))", NSFAttribute, anAttributeValue, NSFAttribute, anAttributeValue, NSFAttribute, anAttributeValue, NSFAttribute, anAttributeValue];
766
786
  [segment appendString:value];
767
787
  } else {
768
788
  switch (match) {
769
789
  case NSFEqualTo:
770
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ = '%@') OR (%@ GLOB '%@.*' AND %@ = '%@') OR (%@ GLOB '*.%@.*' AND %@ = '%@') OR (%@ GLOB '*.%@' AND %@ = '%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
790
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ = '%@') OR (%@ GLOB '%@.*' AND %@ = '%@') OR (%@ GLOB '*.%@.*' AND %@ = '%@') OR (%@ GLOB '*.%@' AND %@ = '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
771
791
  [segment appendString:value];
772
792
  break;
773
793
  case NSFBeginsWith:
774
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ GLOB '%@*') OR (%@ GLOB '%@.*' AND %@ GLOB '%@*') OR (%@ GLOB '*.%@.*' AND %@ GLOB '%@*') OR (%@ GLOB '*.%@' AND %@ GLOB '%@*')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
794
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ GLOB '%@*') OR (%@ GLOB '%@.*' AND %@ GLOB '%@*') OR (%@ GLOB '*.%@.*' AND %@ GLOB '%@*') OR (%@ GLOB '*.%@' AND %@ GLOB '%@*'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
775
795
  [segment appendString:value];
776
796
  break;
777
797
  case NSFContains:
778
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ GLOB '%@') OR (%@ GLOB '%@.*' AND %@ GLOB '%@') OR (%@ GLOB '*.%@.*' AND %@ GLOB '%@') OR (%@ GLOB '*.%@' AND %@ GLOB '%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
798
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ GLOB '%@') OR (%@ GLOB '%@.*' AND %@ GLOB '%@') OR (%@ GLOB '*.%@.*' AND %@ GLOB '%@') OR (%@ GLOB '*.%@' AND %@ GLOB '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
779
799
  [segment appendString:value];
780
800
  break;
781
801
  case NSFEndsWith:
782
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ GLOB '*%@') OR (%@ GLOB '%@.*' AND %@ GLOB '*%@') OR (%@ GLOB '*.%@.*' AND %@ GLOB '*%@') OR (%@ GLOB '*.%@' AND %@ GLOB '*%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
802
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ GLOB '*%@') OR (%@ GLOB '%@.*' AND %@ GLOB '*%@') OR (%@ GLOB '*.%@.*' AND %@ GLOB '*%@') OR (%@ GLOB '*.%@' AND %@ GLOB '*%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
783
803
  [segment appendString:value];
784
804
  break;
785
805
  case NSFInsensitiveEqualTo:
786
806
  aValue = [aValue uppercaseString];
787
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND upper(%@) = '%@') OR (%@ GLOB '%@.*' AND upper(%@) = '%@') OR (%@ GLOB '*.%@.*' AND upper(%@) = '%@') OR (%@ GLOB '*.%@' AND upper(%@) = '%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
807
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND upper(%@) = '%@') OR (%@ GLOB '%@.*' AND upper(%@) = '%@') OR (%@ GLOB '*.%@.*' AND upper(%@) = '%@') OR (%@ GLOB '*.%@' AND upper(%@) = '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
788
808
  [segment appendString:value];
789
809
  break;
790
810
  case NSFInsensitiveBeginsWith:
791
811
  aValue = [aValue uppercaseString];
792
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND upper(%@) GLOB '%@*') OR (%@ GLOB '%@.*' AND upper(%@) GLOB '%@*') OR (%@ GLOB '*.%@.*' AND upper(%@) GLOB '%@*') OR (%@ GLOB '*.%@' AND upper(%@) GLOB '%@*')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
812
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND upper(%@) GLOB '%@*') OR (%@ GLOB '%@.*' AND upper(%@) GLOB '%@*') OR (%@ GLOB '*.%@.*' AND upper(%@) GLOB '%@*') OR (%@ GLOB '*.%@' AND upper(%@) GLOB '%@*'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
793
813
  [segment appendString:value];
794
814
  break;
795
815
  case NSFInsensitiveContains:
796
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ LIKE '%@') OR (%@ GLOB '%@.*' AND %@ LIKE '%@') OR (%@ GLOB '*.%@.*' AND %@ LIKE '%@') OR (%@ GLOB '*.%@' AND %@ LIKE '%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
816
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ LIKE '%@') OR (%@ GLOB '%@.*' AND %@ LIKE '%@') OR (%@ GLOB '*.%@.*' AND %@ LIKE '%@') OR (%@ GLOB '*.%@' AND %@ LIKE '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
797
817
  [segment appendString:value];
798
818
  break;
799
819
  case NSFInsensitiveEndsWith:
800
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ LIKE '%%%@') OR (%@ GLOB '%@.*' AND %@ LIKE '%%%@') OR (%@ GLOB '*.%@.*' AND %@ LIKE '%%%@') OR (%@ GLOB '*.%@' AND %@ LIKE '%%%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
820
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ LIKE '%%%@') OR (%@ GLOB '%@.*' AND %@ LIKE '%%%@') OR (%@ GLOB '*.%@.*' AND %@ LIKE '%%%@') OR (%@ GLOB '*.%@' AND %@ LIKE '%%%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
801
821
  [segment appendString:value];
802
822
  break;
803
823
  case NSFGreaterThan:
804
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ > '%@') OR (%@ GLOB '%@.*' AND %@ > '%@') OR (%@ GLOB '*.%@.*' AND %@ > '%@') OR (%@ GLOB '*.%@' AND %@ > '%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
824
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ > '%@') OR (%@ GLOB '%@.*' AND %@ > '%@') OR (%@ GLOB '*.%@.*' AND %@ > '%@') OR (%@ GLOB '*.%@' AND %@ > '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
805
825
  [segment appendString:value];
806
826
  break;
807
827
  case NSFLessThan:
808
- value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ < '%@') OR (%@ GLOB '%@.*' AND %@ < '%@') OR (%@ GLOB '*.%@.*' AND %@ < '%@') OR (%@ GLOB '*.%@' AND %@ < '%@')", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
828
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ = '%@' AND %@ < '%@') OR (%@ GLOB '%@.*' AND %@ < '%@') OR (%@ GLOB '*.%@.*' AND %@ < '%@') OR (%@ GLOB '*.%@' AND %@ < '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
829
+ [segment appendString:value];
830
+ break;
831
+ case NSFNotEqualTo:
832
+ value = [[NSMutableString alloc]initWithFormat:@"((%@ <> '%@' AND %@ <> '%@') OR (%@ GLOB '%@.*' AND %@ <> '%@') OR (%@ GLOB '*.%@.*' AND %@ <> '%@') OR (%@ GLOB '*.%@' AND %@ <> '%@'))", NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue, NSFAttribute, anAttributeValue, NSFValue, aValue];
809
833
  [segment appendString:value];
834
+
810
835
  break;
811
836
  }
812
837
  }
@@ -826,6 +851,56 @@
826
851
  [segment appendString:value];
827
852
 
828
853
  // Free allocated resources
854
+ } else if (YES == [aValue isKindOfClass:[NSNull class]]) {
855
+ NSString *NULLStringValue = NSFStringFromNanoDataType (NSFNanoTypeNULL);
856
+ switch (match) {
857
+ case NSFEqualTo:
858
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ = '%@') OR (%@ GLOB '%@.*' AND %@ = '%@') OR (%@ GLOB '*.%@.*' AND %@ = '%@') OR (%@ GLOB '*.%@' AND %@ = '%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
859
+ [segment appendString:value];
860
+ break;
861
+ case NSFNotEqualTo:
862
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ <> '%@') OR (%@ GLOB '%@.*' AND %@ <> '%@') OR (%@ GLOB '*.%@.*' AND %@ <> '%@') OR (%@ GLOB '*.%@' AND %@ <> '%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
863
+ [segment appendString:value];
864
+ break;
865
+ case NSFBeginsWith:
866
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ GLOB '%@*') OR (%@ GLOB '%@.*' AND %@ GLOB '%@*') OR (%@ GLOB '*.%@.*' AND %@ GLOB '%@*') OR (%@ GLOB '*.%@' AND %@ GLOB '%@*')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
867
+ [segment appendString:value];
868
+ break;
869
+ case NSFContains:
870
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ GLOB '%@') OR (%@ GLOB '%@.*' AND %@ GLOB '%@') OR (%@ GLOB '*.%@.*' AND %@ GLOB '%@') OR (%@ GLOB '*.%@' AND %@ GLOB '%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
871
+ [segment appendString:value];
872
+ break;
873
+ case NSFEndsWith:
874
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ GLOB '*%@') OR (%@ GLOB '%@.*' AND %@ GLOB '*%@') OR (%@ GLOB '*.%@.*' AND %@ GLOB '*%@') OR (%@ GLOB '*.%@' AND %@ GLOB '*%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
875
+ [segment appendString:value];
876
+ break;
877
+ case NSFInsensitiveEqualTo:
878
+ aValue = [aValue uppercaseString];
879
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND upper(%@) = '%@') OR (%@ GLOB '%@.*' AND upper(%@) = '%@') OR (%@ GLOB '*.%@.*' AND upper(%@) = '%@') OR (%@ GLOB '*.%@' AND upper(%@) = '%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
880
+ [segment appendString:value];
881
+ break;
882
+ case NSFInsensitiveBeginsWith:
883
+ aValue = [aValue uppercaseString];
884
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND upper(%@) GLOB '%@*') OR (%@ GLOB '%@.*' AND upper(%@) GLOB '%@*') OR (%@ GLOB '*.%@.*' AND upper(%@) GLOB '%@*') OR (%@ GLOB '*.%@' AND upper(%@) GLOB '%@*')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
885
+ [segment appendString:value];
886
+ break;
887
+ case NSFInsensitiveContains:
888
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ LIKE '%@') OR (%@ GLOB '%@.*' AND %@ LIKE '%@') OR (%@ GLOB '*.%@.*' AND %@ LIKE '%@') OR (%@ GLOB '*.%@' AND %@ LIKE '%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
889
+ [segment appendString:value];
890
+ break;
891
+ case NSFInsensitiveEndsWith:
892
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ LIKE '%%%@') OR (%@ GLOB '%@.*' AND %@ LIKE '%%%@') OR (%@ GLOB '*.%@.*' AND %@ LIKE '%%%@') OR (%@ GLOB '*.%@' AND %@ LIKE '%%%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
893
+ [segment appendString:value];
894
+ break;
895
+ case NSFGreaterThan:
896
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ > '%@') OR (%@ GLOB '%@.*' AND %@ > '%@') OR (%@ GLOB '*.%@.*' AND %@ > '%@') OR (%@ GLOB '*.%@' AND %@ > '%@')", NSFAttribute, NSFDatatype, NULLStringValue, aValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
897
+ [segment appendString:value];
898
+ break;
899
+ case NSFLessThan:
900
+ value = [[NSMutableString alloc]initWithFormat:@"(%@ = '%@' AND %@ < '%@') OR (%@ GLOB '%@.*' AND %@ < '%@') OR (%@ GLOB '*.%@.*' AND %@ < '%@') OR (%@ GLOB '*.%@' AND %@ < '%@')", NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue, NSFAttribute, anAttributeValue, NSFDatatype, NULLStringValue];
901
+ [segment appendString:value];
902
+ break;
903
+ }
829
904
  }
830
905
 
831
906
  return segment;
@@ -872,16 +947,15 @@
872
947
  {
873
948
  id theResults = results;
874
949
 
875
- if ([sort count] > 0) {
876
- NSMutableArray *cocoaSortDescriptors = [NSMutableArray new];
877
-
878
- for (NSFNanoSortDescriptor *descriptor in sort) {
879
- NSString *targetKeyPath = [[NSString alloc]initWithFormat:@"rootObject.%@", descriptor.attribute];
880
- NSSortDescriptor *cocoaSort = [[NSSortDescriptor alloc]initWithKey:targetKeyPath ascending:descriptor.isAscending];
881
- [cocoaSortDescriptors addObject:cocoaSort];
882
- }
883
-
950
+ if ([_sort count] > 0) {
884
951
  if (NSFReturnObjects == theReturnType) {
952
+ NSMutableArray *cocoaSortDescriptors = [NSMutableArray new];
953
+
954
+ for (NSFNanoSortDescriptor *descriptor in _sort) {
955
+ NSString *targetKeyPath = [[NSString alloc]initWithFormat:@"rootObject.%@", descriptor.attribute];
956
+ NSSortDescriptor *cocoaSort = [[NSSortDescriptor alloc]initWithKey:targetKeyPath ascending:descriptor.isAscending];
957
+ [cocoaSortDescriptors addObject:cocoaSort];
958
+ }
885
959
  theResults = [[results allValues]sortedArrayUsingDescriptors:cocoaSortDescriptors];
886
960
  } else {
887
961
  theResults = [results allKeys];
@@ -903,27 +977,27 @@
903
977
  NSFOrderedDictionary *values = [NSFOrderedDictionary new];
904
978
 
905
979
  values[@"NanoSearch address"] = [NSString stringWithFormat:@"%p", self];
906
- values[@"Document store"] = [nanoStore dictionaryDescription];
907
- values[@"Attributes to be returned"] = (attributesToBeReturned ? [attributesToBeReturned componentsJoinedByString:@","] : @"All");
908
- values[@"Key"] = (key ? key : @"<nil>");
909
- values[@"Attribute"] = (attribute ? attribute : @"<nil>");
910
- values[@"Value"] = (value ? value : @"<nil>");
911
- values[@"Match"] = NSFStringFromMatchType(match);
980
+ values[@"Document store"] = [_nanoStore dictionaryDescription];
981
+ values[@"Attributes to be returned"] = (_attributesToBeReturned ? [_attributesToBeReturned componentsJoinedByString:@","] : @"All");
982
+ values[@"Key"] = (_key ? _key : @"<nil>");
983
+ values[@"Attribute"] = (_attribute ? _attribute : @"<nil>");
984
+ values[@"Value"] = (_value ? _value : @"<nil>");
985
+ values[@"Match"] = NSFStringFromMatchType(_match);
912
986
 
913
987
  NSMutableArray *tempExpressions = [NSMutableArray new];
914
- for (NSFNanoExpression *expression in expressions) {
988
+ for (NSFNanoExpression *expression in _expressions) {
915
989
  [tempExpressions addObject:[expression description]];
916
990
  }
917
991
  values[@"Expressions"] = ([tempExpressions count] > 0 ? tempExpressions : @"<nil>");
918
992
 
919
- values[@"Group values?"] = (groupValues ? @"YES" : @"NO");
993
+ values[@"Group values?"] = (_groupValues ? @"YES" : @"NO");
920
994
 
921
995
  NSString *tempSQL = [self sql];
922
996
  values[@"SQL"] = (tempSQL ? tempSQL : @"<nil>");
923
- values[@"Sort"] = (sort ? sort : @"<nil>");
924
- values[@"Filter class"] = (filterClass ? filterClass : @"<nil>");
925
- values[@"Offset"] = @(offset);
926
- values[@"Limit"] = @(limit);
997
+ values[@"Sort"] = (_sort ? _sort : @"<nil>");
998
+ values[@"Filter class"] = (_filterClass ? _filterClass : @"<nil>");
999
+ values[@"Offset"] = @(_offset);
1000
+ values[@"Limit"] = @(_limit);
927
1001
 
928
1002
  return values;
929
1003
  }