Skip to content

Commit

Permalink
Merge branch 'master' into and-query
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrezza authored Jul 14, 2023
2 parents fb89260 + 04f81e8 commit 3fe2e30
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions Parse/Parse/Internal/Query/State/PFMutableQueryState.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

- (void)includeKey:(NSString *)key;
- (void)includeKeys:(NSArray<NSString *> *)keys;
- (void)includeAll;

///--------------------------------------
#pragma mark - Excludes
Expand Down
4 changes: 4 additions & 0 deletions Parse/Parse/Internal/Query/State/PFMutableQueryState.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ - (void)includeKeys:(NSArray<NSString *> *)keys {
}
}

- (void)includeAll {
[self includeKey:@"*"];
}

///--------------------------------------
#pragma mark - Excludes
///--------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions Parse/Parse/Source/PFQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ typedef void (^PFQueryArrayResultBlock)(NSArray<PFGenericObject> *_Nullable obje
*/
- (instancetype)includeKeys:(NSArray<NSString *> *)keys;

/**
Make the query include all `PFObject`s that have a reference.
@return The same instance of `PFQuery` as the receiver. This allows method chaining.
*/
- (instancetype)includeAll;

/**
Make the query restrict the fields of the returned `PFObject`s to exclude the provided key.
Expand Down
6 changes: 6 additions & 0 deletions Parse/Parse/Source/PFQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ - (instancetype)includeKeys:(NSArray<NSString *> *)keys {
return self;
}

- (instancetype)includeAll {
[self checkIfCommandIsRunning];
[self.state includeAll];
return self;
}

///--------------------------------------
#pragma mark - Exclude
///--------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions Parse/Tests/Unit/QueryStateUnitTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ - (void)testIncludeMultipleKeys {
XCTAssertEqualObjects(state.includedKeys, includedKeys);
}

- (void)testIncludeAll {
PFMutableQueryState *state = [[PFMutableQueryState alloc] initWithParseClassName:@"Yarr"];
[state includeAll];

NSSet *includedKeys = PF_SET(@"*");
XCTAssertEqualObjects(state.includedKeys, includedKeys);
}

- (void)testExcludeKeys {
PFMutableQueryState *state = [[PFMutableQueryState alloc] initWithParseClassName:@"Yarr"];
[state excludeKey:@"a"];
Expand Down

0 comments on commit 3fe2e30

Please sign in to comment.