Skip to content

Commit 04f81e8

Browse files
authored
feat: Add support to include all pointers with PFQuery.includeAll (#1734)
1 parent 07f98fe commit 04f81e8

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

Parse/Parse/Internal/Query/State/PFMutableQueryState.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969

7070
- (void)includeKey:(NSString *)key;
7171
- (void)includeKeys:(NSArray<NSString *> *)keys;
72+
- (void)includeAll;
7273

7374
///--------------------------------------
7475
#pragma mark - Excludes

Parse/Parse/Internal/Query/State/PFMutableQueryState.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ - (void)includeKeys:(NSArray<NSString *> *)keys {
166166
}
167167
}
168168

169+
- (void)includeAll {
170+
[self includeKey:@"*"];
171+
}
172+
169173
///--------------------------------------
170174
#pragma mark - Excludes
171175
///--------------------------------------

Parse/Parse/Source/PFQuery.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ typedef void (^PFQueryArrayResultBlock)(NSArray<PFGenericObject> *_Nullable obje
107107
*/
108108
- (instancetype)includeKeys:(NSArray<NSString *> *)keys;
109109

110+
/**
111+
Make the query include all `PFObject`s that have a reference.
112+
113+
@return The same instance of `PFQuery` as the receiver. This allows method chaining.
114+
*/
115+
- (instancetype)includeAll;
116+
110117
/**
111118
Make the query restrict the fields of the returned `PFObject`s to exclude the provided key.
112119

Parse/Parse/Source/PFQuery.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,12 @@ - (instancetype)includeKeys:(NSArray<NSString *> *)keys {
426426
return self;
427427
}
428428

429+
- (instancetype)includeAll {
430+
[self checkIfCommandIsRunning];
431+
[self.state includeAll];
432+
return self;
433+
}
434+
429435
///--------------------------------------
430436
#pragma mark - Exclude
431437
///--------------------------------------

Parse/Tests/Unit/QueryStateUnitTests.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ - (void)testIncludeMultipleKeys {
215215
XCTAssertEqualObjects(state.includedKeys, includedKeys);
216216
}
217217

218+
- (void)testIncludeAll {
219+
PFMutableQueryState *state = [[PFMutableQueryState alloc] initWithParseClassName:@"Yarr"];
220+
[state includeAll];
221+
222+
NSSet *includedKeys = PF_SET(@"*");
223+
XCTAssertEqualObjects(state.includedKeys, includedKeys);
224+
}
225+
218226
- (void)testExcludeKeys {
219227
PFMutableQueryState *state = [[PFMutableQueryState alloc] initWithParseClassName:@"Yarr"];
220228
[state excludeKey:@"a"];

0 commit comments

Comments
 (0)