Android Realm copyToRealmOrUpdate updates existing fields

When using copyToRealmOrUpdate, it also overrides fields with existing values. I expect it to only update the fields that I gave, and use existing values ​​for other fields.

I saw this problem for createOrUpdateFromJson: https://github.com/realm/realm-java/issues/933 cmelchior says this:

It is not possible to tell the difference between a value not set and this is the default value, so it must override all the properties.

I wanted to create a problem with improving shortcuts for the area, but instead I will ask about it first. Is it really impossible? Because that would be a big improvement for me.

Thanks!

+5
source share
1 answer

Please note that there is a difference between using Realm.copyToRealmOrupdate(RealmObject) and Realm.createOrUpdateFromJson(Json)

The answer I gave is true for copyToRealmOrUpdate() for example. you cannot distinguish the following in Java:

 boolean bool1; boolean bool2 = false; 

For JSON, this is different where you can determine if a property is missing at all. However, the current implementation does not work that way. We are currently trying to merge a Pull request that really has the behavior you are looking for. You can follow the progress here: https://github.com/realm/realm-java/pull/1022

+3
source

All Articles