realm-swift
realm-swift copied to clipboard
Setting the same RLMArray to a relationship drops the data
Not sure, how valid this case is but:
Imagine object A with to-many relationship to B.
Later during mapping I'm evaluating target value for that relationship based on network response. It appears, that there are no changes, so caller of merge routing simply performs -[RLMObject setValue:forKey:]
with the same RLMArray as it was.
The result is quite unexpected: all relationship data is gone! It seems, that you're not expecting the same object for relationship in RLMAccessor
Handling the simple case of of assigning a property to itself would be simple enough by just checking if the linkviews are the same, but making it robust in the face of wrapper objects and such would require copying the data out of the input object.
@tgoyne not sure I'm doing it correctly, but decided to reuse existing RLMArray
by calling addObject:
Later I'm setting it to the relationship and it gets purged by code from RLMAccessor above.
I've fixed it already in my code, but assuming this to be a bug :)