-
-
Notifications
You must be signed in to change notification settings - Fork 878
Parse query from LocalDataStore for object with PFRelation returns empty #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you share a full code snippet that fails for you. An ideal scenario would be a failing unit test or a full repro project on github. |
Here is a code snippet with parts of the code I use : https://gitlab.com/snippets/7703 |
Has this been resolved? I am also having this same issues (PFRelation queries in the localdatatsore). |
I'm getting this with 1.8.5. Let me know if there's anything I can do to help squash. |
Hey guys, the most helpful thing here would be to get a repro project from anyone of you that has this issue reproduced. Or a failing unit test? |
Hi @nlutsenko, I took some time to further investigate this issue and realized that the issue was not in querying the localDatastore but actually pinning large amounts of objects to the localDatastore using the method +(BFTask *)pinAllInBackground:(NSArray *)objects. I realized this because when I pinned (using pinAllInBackground:) and then did a localDataStore query for a PFRelation of only 6-10 objects, I was able to get my desired results. On the other hand, when I did the same two methods with a PFRelation of ~600 and ~1000 objects, I failed to get the objects when I did the localDatastore query (yet the BFTask returned a result of 1 which made me think the pinning work). To test this assumption, I decided to iterate through the PFRelation of ~1000 objects, and then individually pin each object using - (BFTask *)pinInBackground. After doing this, I did the same local query on the PFRelation and was able to retrieve my desired objects. Hope this helps. Happy to clarify. |
Great, this definetly helps. Any chance you can setup a project that shows the issue? |
Yeah, I will build something now. Shouldn't take too long. |
@nlutsenko I just shared you with a fairly simple that replicates this issue. It logs the results of the query to server, the pin task, and the local query to show what is going wrong. |
@dtaitz, many thanks for the repro project, I can see the issue now. I'll look into the ways to fix it overall - but in the meantime, removing the currentUser from inside the relation fixes the problem in your case. |
Thank you! That makes sense. I appreciate you pointing that out I appreciate you taking the time to help! On Sat, Oct 10, 2015 at 8:49 PM, Nikita Lutsenko [email protected]
|
@nlutsenko removing the Current User from the PFRelation solves the issue on the sample project I gave you but not on my actual project. I keep coming across this lock with [User currentUser] when trying to find workarounds for my current problem with querying the localdatastore with PFRelations. https://gist.github.com/dtaitz/add05892cec971f40766 I update my [User currentUser] a decent amount at launch of the app but have not seen this issue until recently. Please let me know what I can do to help |
@nlutsenko I am still experiencing this issue. Is there anything I can do to help figure it out? |
@dtaitz, the thing is - I think I know where the problem is coming from, but unfortunately I don't have a solution for our codebase that solves this just yet. Our decoding logic resets the relations for any object whenever there is an update of data coming from the server for that object. If it happens after the fact that we were able to cache the objects that we know about on the client, but before we were able to persist it to the LDS - you get the known objects on a query reset to the previous state, which means that relations doesn't properly report known objects. One of the suggestions at the current time for you to fix it, that I have is to:
Another way would require more work, but probably is better long-term: do not use relations directly, but rather create your own table that connects 2 users together. This approach would give you an ability to perform the same query, but instead of relying on the relation field - get the query for a different object class and work based on that. Roughly - recreate relations from scratch by yourself :) This approach is also slightly more flexible, since you can query the objects the other way around aka bi-directional queries from both the owner of the friendship as well as the user who is a friend, so you can display to both of them the fact that the friendship exists.
Let me know if any piece of this above doesn't make sense or is not clear. (tried my best, but it's somewhat hard to explain). |
@nlutsenko thanks for getting back to me. I will look into both approaches now. The second one is definitely more extensive! Do you think there will be any performance issues with the second approach at scale? I can imagine quite a few objects needing to be created and stored in the LDS in that case. Thanks again! |
Performance: The second approach is also going to give you slightly better security, since you can specify ACL on the FriendshipConnection object only to 2 users, which will restrict reading of that information only to those users. |
@nlutsenko that makes sense. I will let you know how it goes. As always, appreciate you taking the time to explain this. |
No problem, always happy to help. :D |
Any news on this? I'm currently experiencing this issue in a setup with two classes, let's say The steps I'm doing:
Unfortunately, I can't apply any of these two workarounds above due to time and architectural limitations... Any help would be greatly appreciated :) |
@nlutsenko Sorry for bumping - I'm just wondering if you've seen the last message :) A "no" would be a good answer too, I just need to do something about this in our app asap. In case nothing changed with this issue, I guess I'll have to use the first workaround idea, somehow. |
I guess we just cannot create relationships on objects until they are saved in the cloud. I am trying to create a parse one-to-many relation in a network independent way. I guess my issue is similar to this http://stackoverflow.com/questions/15327255/how-to-make-sure-saving-parseobject-and-parserelation-using-saveeventually. It is currently impossible to add PFRelations to PFObjects saved with saveEventually (local datastore is enabled). Trying to fetch a relation on an object that was saved offline in this manner fails with the "nilError" so struggling to understand what is wrong or how to circumvent this... if this is intended..
|
@nickynick @livingstonef Are you still experiencing this issue? |
I am trying to implement Local datastore in my application but I have an issue when I need to query relation from local Datastore.
Here is my query :
This query returns what I'm looking for when fetched by network but then I Pin all the results and re-query from localDatastore, and the result is empty.
I am using the newest Parse iOS SDK (1.8.1)
This issue is linked with these topics :
The text was updated successfully, but these errors were encountered: