-
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
Fix a few bugs with frozen objects in obj-c #6570
Conversation
How we initialize the schema results in RealmCoordinator's schema cache not containing computed properties, so we need to call set_schema_subset() on frozen Realms to populate them.
@@ -87,6 +87,39 @@ - (void)testLinkingObjectsOnUnmanagedObject { | |||
@"Linking objects notifications are only supported on managed objects."); | |||
} | |||
|
|||
- (void)testLinkingObjectsOnFrozenObject { | |||
NSArray *(^asArray)(id) = ^(id arrayLike) { |
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.
Nice.
@@ -1354,7 +1354,7 @@ - (void)testIsFrozen { | |||
IntObject *frozen = [managed freeze]; | |||
XCTAssertFalse(standalone.isFrozen); | |||
XCTAssertFalse(managed.isFrozen); | |||
XCTAssertFalse(frozen.isFrozen); |
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.
Was this a holdover to get tests passing?
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.
No, it was just a mistake while writing the test.
@@ -1017,6 +1017,7 @@ - (RLMRealm *)frozenCopy { | |||
try { | |||
RLMRealm *realm = [[RLMRealm alloc] initPrivate]; | |||
realm->_realm = _realm->freeze(); | |||
realm->_realm->set_schema_subset(_realm->schema()); |
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.
Why is this needed?
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 commit message says why.
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.
Ah-ha, thanks. Makes sense
Linking objects on frozen objects were only tested in Swift and not obj-c, and so unsurprisingly the obj-c version had a dumb bug. -[RLMObject isFrozen] was tested, but the test was wrong. The other change here is just a bit of error checking to give a better error when the user does something that can't work.
Fixes #6568.