I have a PFUser
object with several PFRelation
pointing to other objects. When I run the following code:
PFRelation *relation = [[PFUser currentUser] relationForKey:@"Relation"];
PFQuery *query = [relation query];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
NSLog(@"%@", objects);
}];
it works fine. However, when I want to do the same from the local data store:
PFRelation *relation = [[PFUser currentUser] relationForKey:@"Relation"];
PFQuery *query = [[relation query] fromLocalDataStore]; // !!!
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error){
NSLog(@"%@", objects);
}];
it returns nothing, despite the fact I've pinned both my user and related objects with [myObject pinInBackground]
.
Why PFRelation
queries does not support fromLocalDataStore
? What I'm doing wrong?
Have the same problem in parse 1.7.5 (release notes mentions that they fixed this bug, but still not working for me)
You can make it working with executing separate query for relation you have for each pinning object (maybe there is a way to do it with all objects at once?). And then pin results of relation query.
After that querying from local datastore starts working fine.
It's a Parse bug. It can be also reproduced with Android SDK. I'm not sure on iOS, but on Android I have found a way how to make it work.
You need to have a
Pointer
in "related" classes to theParseObject
which hasRelation
s.In your case, you have a
PFUser
which has severalPFRelation
s. If you add aPFPointer
to yourPFUser
in "related" classes, query from the local datastore would work just fine.Or for the case from my link above - If
Comment
class would have aPointer
to aPost
class everything would work fine.I've created a bug report for this issue which is
So it looks like it's a bug
In the meanwhile, I've converted all my
PFRelations
to arrays of pointers to relatedPFObject
s. Not as fancy asPFRelation
, but works fine with local data storage.Update: parse solved the issue in Parse SDK v.1.7.3