-
Notifications
You must be signed in to change notification settings - Fork 43
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
Relationships Must Be Marked As Optional #14
Comments
Mandatory relationships should be working now. |
@mikejohnstn, which branch(s) does your comment apply to? I'm using the 'master' branch and I'm having an issue that looks like "Relationships must be marked optional". Mine are not. Is that supported in master? Or do I need to upgrade to the 'develop' branch or mark my relationships optional? (Neither is a great option..) Thanks. |
@CapoChino may i ask you what steps should i follow to reproduce the bug, and the problem you're seeing?. Just in case, we've fixed a relationships-related glitch, in develop ("Upcoming 0.6.2 release"). #181 Thanks! |
Hi Jorge, I don't have an easy test case yet. I can create one if needed. But first, let's cover the basics: My app has several relationships. Most are optional and have inverses. No many-to-many.
I found the problem happened the same on the 'develop' and 'master' branches. I'd love to re-establish relationship requirements and object validation and still have Simperium work. Do you already have a test case we can use for this? Basically, we want a large object graph (with mandatory relationships) in the cloud to be sync'd down to the device. Thanks for your help and active contribution to this project! Casey |
I believe I was mistaken, come to think of it. We'll need to test and confirm. If they're still not working, I believe #121 is one possible solution. |
@CapoChino sorry to hear you're having troubles!. May i ask you a couple questions regarding the data model?.
Basically, i'd love to recreate a data model resembling the one you're currently using, so we can replicate the exact same scenario. Thanks in advance! |
I've uploaded a simplified version of my Xcode data model here: https://www.dropbox.com/sh/k3jswiwophbj39s/XNhTVj9wPE You can download this file and open in Xcode or include the model in a test project. Let me know if there's anything else I can provide. Thank you, |
Oh, also, @jleandroperez, I just wanted confirmation that you do expect mandatory relationships to work. It seems like Mike doesn't even expect them to work... Thanks |
@CapoChino thanks for posting the model!. I'll be building a sample app to replicate the issue. Regarding whether if it should work or not, to be honest with you, so far i've been using optional relationships all along, since it gives you more flexibility (you can add EntityA, EntityB, and when needed, if needed, wire them together). I'll take a look and get back to you soon! |
I'm suspecting the problem will arise for A --related--> B,when A arrives before B (asynchronously) and tries to save the context. Since the relationship is mandatory, A would be considered invalid until B is local and can be referenced via a managed object ID. |
@CapoChino hey there!. I've been checking the issues you've been seeing. Every entity managed by Simperium has its own "processor thread", where changes are applied (and saved using a temporary managedObjectContext), to provide a high level of parallelism, and significantly enhance speed. As Mike pointed out, due to the asynchronous nature of the library, there is no way to warrantee that a group of objects will be transferred at the same time, which makes it impossible to safely set relationships before persisting to the store coordinator. I'm afraid to say that, for the time being, mandatory relationships won't work correctly. There might be a way around, though. The 'Embedded Entities' pull request should allow you to "embed" objects, one inside the other, so when they get transferred, you don't have to wait for anything else to go through the network: #121 We'll be working on merging that in the future. Sorry about any issues this might cause! |
Well, that's unfortunate, especially since I was expecting them to work based on this thread. But it's not a deal-breaker. I may be able to ship my app with all relationships marked as optional in order to get the benefits of Simperuim. However, I'm having another problem with background NSManagedContexts. I'll address that in another issue. Thanks for looking into this. |
Found this issue after running into exactly the same issue as @CapoChino. Seeing that your conversation took place 5 months ago: Are there any news on this? If not (that is, if optional relationships are still a requirement), I guess you should clearly state that in your documentation, since many people use mandatory relationships per default. And: Thanks for your contributions to what seems to be an awesome project! :) |
Closing in favor of Issue #442 |
In order for Simperium to correct sync an object graph, relationships must always be marked as optional. This appears to be a requirement since entity data may arrive at the client in an undefined sequence. However, the client's own validation logic may require certain relationships to be properly indicated as mandatory.
It would be helpful for relationships to be defined as either optional or mandatory, as required by a specific application, and for simperium to sync correctly, regardless of whether or not relationships are marked as optional.
The text was updated successfully, but these errors were encountered: