Skip to content
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

Merged
merged 3 commits into from
Jun 10, 2020
Merged

Fix a few bugs with frozen objects in obj-c #6570

merged 3 commits into from
Jun 10, 2020

Conversation

tgoyne
Copy link
Member

@tgoyne tgoyne commented Jun 10, 2020

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.

tgoyne added 3 commits June 9, 2020 16:07
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.
@tgoyne tgoyne requested a review from jsflax June 10, 2020 01:12
@tgoyne tgoyne self-assigned this Jun 10, 2020
@@ -87,6 +87,39 @@ - (void)testLinkingObjectsOnUnmanagedObject {
@"Linking objects notifications are only supported on managed objects.");
}

- (void)testLinkingObjectsOnFrozenObject {
NSArray *(^asArray)(id) = ^(id arrayLike) {
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Member Author

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());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Member Author

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.

Copy link
Contributor

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

@tgoyne tgoyne merged commit 6011b7f into master Jun 10, 2020
@tgoyne tgoyne deleted the tg/freeze-bugs branch June 10, 2020 16:19
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Freeze objects: isFrozen and linkingObjects don't work
2 participants