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 possibly missing parent update when setting null values #5334

Merged
merged 1 commit into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### Fixed
* <How do the end-user experience this issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Query parser would not accept "in" as a property name ([#5312](https://github.com/realm/realm-core/issues/5312))
* Application would sometimes crash with exceptions like 'KeyNotFound' or assertion "has_refs()". Other issues indicating file corruption may also be fixed by this. The one mentioned here is the one that lead to solving the problem. ([#5283](https://github.com/realm/realm-core/issues/5283), since v6.0.0)

### Breaking changes
* SchemaMode::ResetFile renamed to SchemaMode::SoftResetFile.
Expand Down
7 changes: 5 additions & 2 deletions src/realm/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ inline void nullify_set(Obj& obj, ColKey origin_col_key, T target)

void Obj::nullify_link(ColKey origin_col_key, ObjLink target_link)
{
ensure_writeable();
// ensure_writeable();
Copy link
Contributor

Choose a reason for hiding this comment

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

@jedelbo shouldn't this be deleted or an explanation added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This can be deleted. Just forgot.


ColKey::Idx origin_col_ndx = origin_col_key.get_index();
Allocator& alloc = get_alloc();
Expand Down Expand Up @@ -2161,6 +2161,8 @@ inline void Obj::do_set_null(ColKey col_key)
values.set_parent(&fields, col_ndx.val + 1);
values.init_from_parent();
values.set_null(m_row_ndx);

sync(fields);
}

template <>
Expand All @@ -2178,6 +2180,8 @@ inline void Obj::do_set_null<ArrayString>(ColKey col_key)
values.set_spec(const_cast<Spec*>(&get_spec()), spec_ndx);
values.init_from_parent();
values.set_null(m_row_ndx);

sync(fields);
}

Obj& Obj::set_null(ColKey col_key, bool is_default)
Expand All @@ -2194,7 +2198,6 @@ Obj& Obj::set_null(ColKey col_key, bool is_default)
}

update_if_needed();
ensure_writeable();

StringIndex* index = m_table->get_search_index(col_key);
if (index && !m_key.is_unresolved()) {
Expand Down