Skip to content

Commit

Permalink
Merge v10 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Dec 11, 2020
2 parents a738a66 + c689946 commit 1e7cf5d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@

----------------------------------------------

# 10.1.4 Release notes

### Fixed
* You may get assertion "n != realm::npos" when integrating changesets from the server. ([#4180](https://github.com/realm/realm-core/pull/4180), since v10.0.0)

----------------------------------------------

# 10.1.3 Release notes

### Enhancements
Expand Down
3 changes: 3 additions & 0 deletions src/realm/cluster_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,9 @@ ClusterNode::State ClusterTree::insert(ObjKey k, const FieldValues& values)

bool ClusterTree::is_valid(ObjKey k) const
{
if (m_size == 0)
return false;

ClusterNode::State state;
return m_root->try_get(k, state);
}
Expand Down
7 changes: 6 additions & 1 deletion src/realm/obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1972,8 +1972,13 @@ void Obj::assign_pk_and_backlinks(const Obj& other)
Mixed val = other.get_any(col_pk);
this->set_any(col_pk, val);
}
auto nb_tombstones = m_table->m_tombstones->size();

auto copy_links = [this, &other](ColKey col) {
auto copy_links = [this, &other, nb_tombstones](ColKey col) {
if (nb_tombstones != m_table->m_tombstones->size()) {
// Object has been deleted - we are done
return true;
}
auto t = m_table->get_opposite_table(col);
auto c = m_table->get_opposite_column(col);
auto backlinks = other.get_all_backlinks(col);
Expand Down
34 changes: 34 additions & 0 deletions test/test_unresolved_links.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,38 @@ TEST(Unresolved_CondensedIndices)
CHECK_EQUAL(list1.get(2), obj456.get_key());
}

TEST(Unresolved_Recursive)
{
Group g;
auto table = g.add_table_with_primary_key("RecursiveNode", type_ObjectId, "_id");
// Create two link columns. This will create two backlink columns in the target table
// When a tombstone is resurrected, and a backlink in the first backlink column is
// removed and the tombstone is thereby deleted, we should not attempt to find backlinks
// in the second backlink column.
auto col_next = table->add_column(*table, "NextNode");
auto col_children = table->add_column_list(*table, "children");

auto key = table->get_objkey_from_primary_key(ObjectId("5fc929bac4a3964b6d603f4e"));
key = table->create_object_with_primary_key(ObjectId("5fc929bac4a3964b6d603f4d")).set(col_next, key).get_key();

table->create_object_with_primary_key(ObjectId("5fc929bac4a3964b6d603f4c")).set(col_next, key);

// This will delete the tombstone for "5fc929bac4a3964b6d603f4e"
table->create_object_with_primary_key(ObjectId("5fc929bac4a3964b6d603f4e"));

// The following will ensure that objects will be turned into tombstones when invalidated
auto obj = table->create_object_with_primary_key(ObjectId("5fc929bac4a3964b6d603f4b"));
auto ll = obj.get_linklist(col_children);
ll.add(table->get_objkey_from_primary_key(ObjectId("5fc929bac4a3964b6d603f4c")));
ll.add(table->get_objkey_from_primary_key(ObjectId("5fc929bac4a3964b6d603f4d")));
ll.add(table->get_objkey_from_primary_key(ObjectId("5fc929bac4a3964b6d603f4e")));

g.verify();
CHECK_EQUAL(table->nb_unresolved(), 0);
table->get_object_with_primary_key(ObjectId("5fc929bac4a3964b6d603f4c")).invalidate();
table->get_object_with_primary_key(ObjectId("5fc929bac4a3964b6d603f4d")).invalidate();
CHECK_EQUAL(table->nb_unresolved(), 2);
g.verify();
}

#endif

0 comments on commit 1e7cf5d

Please sign in to comment.