-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Copy EmbeddedObject on initializing an unmanaged object #7301
base: master
Are you sure you want to change the base?
Conversation
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.
Just a minor comments
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.
LGTM, only comment It looks like SwiftLint CI Job is failing, because of format issues.
We only want to copy the object if it's managed. |
Realm/RLMObjectBase.mm
Outdated
if (([obj isKindOfClass:cls] && ![(id)cls isEmbedded]) || | ||
([(id)cls isEmbedded] && [obj respondsToSelector:@selector(realm)] && ![obj realm])) { |
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.
if (([obj isKindOfClass:cls] && ![(id)cls isEmbedded]) || | |
([(id)cls isEmbedded] && [obj respondsToSelector:@selector(realm)] && ![obj realm])) { | |
if ([obj isKindOfClass:cls] && (![(id)cls isEmbedded] || ![obj realm])) { |
I think what you have would call isEmbedded
on classes that don't implement it and would accept objects of any type as long as they're an unmanaged embedded object. This also points at some missing tests for initializing an unmanaged object with a value that has an object of a different type in an embedded object field (which copies that object into an unmanaged object of the correct type if all of the required fields are present and have the correct values, and throws an exception if it can't).
so, no more updates on this? 😕 |
27eee84
to
7af1c9c
Compare
d793f69
to
62a7f79
Compare
62a7f79
to
eaca6da
Compare
@tgoyne checking this, I think the changes regarding the comments were made, looking at the original issue I think some test are missing what the original intention was, something like the follow.
Let me know if there are more changes needed on this, or If I should change the current text with the text above. |
When creating an unmanaged copy of a managed object with the embedded object property we should make a copy of this embedded object instead of reusing it.
This is fix #6921