Skip to content
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

Remote Changes Discarded (when defaults values are set in core data model) #547

Open
larryryu opened this issue May 13, 2016 · 0 comments
Open

Comments

@larryryu
Copy link
Contributor

While working on a project we noticed that certain changes were lost on the iOS client.

Attempted Fix: #546 (this work but requires some testing)

Remote Change Discarded (when defaults values are set in core data model)

Model
Assume we have an entity note which have the following attributes

{
    title: <String>
    text: <String>
    likes: <Int> (**default value set to 0 in core data model**)
}

HTTP API

  • Create a note object with http api setting the title to “new note”.
{
    title: “new note”
}
  • Set the text to “some text” using http api
{
    title: “new note”
    text: “some text”
}

This counts as 2 changes and the version should now be "2".

iOS Client
When this object gets to the iOS client, the first change comes and the notes object is created with the following ghost data

{
    title: “new note”
}

however the core data MangedObject is

{
    title: “new note”
    likes: 0
}

when the second change comes in, it gets overwritten by the diff between the ManagedObject in memory and it’s ghostData.

diff = {
    likes =     {
        o = r;
        v = 0;
    };
}

see https://github.com/Simperium/simperium-ios/blob/develop/Simperium/SPChangeProcessor.m#L316
This causes the remote change to be overwritten and thereby losing data. Moreover when the next sync occur the client sends the change that causes “text” to be set back to nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant