-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support upserts #668
Support upserts #668
Conversation
There is some work in Core about this realm/realm-core#5516 |
a82a6b8
to
b578e33
Compare
ac89b51
to
657275d
Compare
This is still in draft. I suggest we update our code once it lands. |
c928512
to
14ba9bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code seems fine to me, but I think we could improve the test coverage of that feature.
Off the top of my head, some tests that are missing:
- A test that upserting an object with a collection different from the original collection is clearing the old collection before populating it with the new items.
- A test that upserting an object with an empty collection clears the old collection.
- Tests that mix and match managed and unmanaged objects.
- A test that upserting an object with a collection where the items of the collection have changes, those changes get applied to the original objects.
is tested in
isn't that implied by 1) , ie.
Doesn't the
Isn't this tested in |
You're right - I misread some of what was going on with the party test. Re: @RealmModel()
class _ObjWithPK {
@PrimaryKey()
late int id;
late _ObjWithPK linkWithPK;
late List<_ObjWithPK> listWithPK;
late _ObjWithoutPK linkWithoutPK;
late List<_ObjWithoutPK> listWithoutPK;
}
@RealmModel()
class _ObjWithoutPK {
late _ObjWithPK linkWithPK;
late List<_ObjWithPK> listWithPK;
late _ObjWithoutPK linkWithoutPK;
late List<_ObjWithoutPK> listWithoutPK;
} And test that a more complex graph with cycles is getting correctly inserted. Again, I don't think there's a bug in the code, but I think I can come up with buggy implementations that pass the Party test. |
I have gathered all test in one test case about friends and parties, with an easy to follow narrative. |
The control flow is dictated by the returns
Co-authored-by: Nikola Irinchev <irinchev@me.com>
Allows to upsert object graphs with
Realm.add(x, update:true)
(andRealm.addAll([x,y], update:true)
)Resolves: #648