Note that there are some explanatory texts on larger screens.

plurals
  1. POParse.com - Strange includeKey issue
    primarykey
    data
    text
    <p>I have a compound query as shown below.</p> <pre><code> - (PFQuery *)queryForPhotos { if (![PFUser currentUser]) { PFQuery *query = [PFQuery queryWithClassName:kPAPPhotoClassKey]; [query setLimit:0]; return query; } // Query for users with the same language level PFQuery *sameLevelUsersQuery = [PFUser query]; [sameLevelUsersQuery whereKey:kWSUserLanguageLevelKey equalTo:[[PAPCache sharedCache] languageLevelForUser:[PFUser currentUser]]]; sameLevelUsersQuery.cachePolicy = kPFCachePolicyNetworkOnly; sameLevelUsersQuery.limit = 1000; PFQuery *photosFromSameLevelUsersQuery = [PFQuery queryWithClassName:kPAPPhotoClassKey]; [photosFromSameLevelUsersQuery whereKey:kPAPPhotoUserKey matchesQuery:sameLevelUsersQuery]; [photosFromSameLevelUsersQuery whereKeyExists:kPAPPhotoPictureKey]; [photosFromSameLevelUsersQuery whereKey:kWSUniversalIsDeletedKey notEqualTo:[NSNumber numberWithBool:YES]]; [photosFromSameLevelUsersQuery includeKey:kWSPhotoCommentObjectForTitleKey]; // THE INCLUDED KEY IN QUESTION [photosFromSameLevelUsersQuery orderByDescending:@"createdAt"]; // A pull-to-refresh should always trigger a network request. [photosFromSameLevelUsersQuery setCachePolicy:kPFCachePolicyNetworkOnly]; return photosFromSameLevelUsersQuery; } </code></pre> <p>If I leave this line in:</p> <pre><code> [photosFromSameLevelUsersQuery includeKey:kWSPhotoCommentObjectForTitleKey]; // THE INCLUDED KEY IN QUESTION </code></pre> <p>Then I get only 1 photoObject that contains a commentObject in that field. However, 3 of the (currently) 26 photos in the DB have commentObjects in that field, therefore I should get 3 photos with something in that field. The one commentObject DOES load with all of it's fields.</p> <p>HOWEVER, if I leave out that <code>includeKey</code> line, then all 3 of the photoObjects with something in that field DO return a commentObject in that field. HOWEVER, in this case the objects are empty and I have to call <code>fetchIfNeeded</code> to retrieve their data.</p> <p>I'd rather not do this and have to reload the tableView on callback if I can get the data loaded the first time the correct way.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload