Skip to content

Commit

Permalink
Fix possibly missing parent update when setting null values
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Mar 17, 2022
1 parent 7ed4f65 commit 6b89fea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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();

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

0 comments on commit 6b89fea

Please sign in to comment.