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

Add an option to only set the properties which actually change #6149

Merged
merged 2 commits into from
May 28, 2019

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented May 20, 2019

In Swift this is done by changing update: Bool to update: UpdatePolicy with the enum options being .all, .changed, and .error, with a deprecated overload for the old parameter types to avoid breaking backwards compatibility. Objective C uses separate methods for create and createOrUpdate, so this sticks with that pattern and adds createOrUpdateChangedInRealm:withValue: for the new behavior.

Closes #5970.

@tgoyne tgoyne self-assigned this May 20, 2019
Adds or updates an existing object into the Realm.
What to do when an object being added to or created in a Realm has a primary key that already exists.
*/
public enum UpdatePolicy: Int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the thinking was behind choosing these names, but they differ from the ones in Realm JS (which, granted, were kinda arbitrary):

    enum UpdateMode {
        Never = 'never',
        Modified = 'modified',
        All = 'all'
    }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably change 'changed' to 'modified' to align them.

'error' is trying to convey that an exception is thrown as opposed to it just not updating the object if it already exists (which is a different thing that might be worth doing).

@bmunkholm
Copy link
Contributor

Should we also update the docs (the guide) to mention this?

@tgoyne tgoyne force-pushed the tg/diffed-updates branch from aa8c1fd to 104f4d7 Compare May 24, 2019 21:06
@tgoyne tgoyne merged commit 99c6e4c into master May 28, 2019
@tgoyne tgoyne deleted the tg/diffed-updates branch May 28, 2019 18:33
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support "diffing object updates"
3 participants