diff --git a/src/impl/realm_coordinator.cpp b/src/impl/realm_coordinator.cpp index 5e7314d3..7f0f6ff2 100644 --- a/src/impl/realm_coordinator.cpp +++ b/src/impl/realm_coordinator.cpp @@ -338,8 +338,10 @@ public: { if (version != m_sg.get_version_of_current_transaction()) { transaction::advance(m_sg, *m_current, version); - // FIXME: needs to copy tables to watch? - m_info.push_back({{}, {}, std::move(m_current->lists)}); + m_info.push_back({ + m_current->table_modifications_needed, + m_current->table_moves_needed, + std::move(m_current->lists)}); m_current = &m_info.back(); return true; } diff --git a/tests/list.cpp b/tests/list.cpp index 7db9a953..37f2381a 100644 --- a/tests/list.cpp +++ b/tests/list.cpp @@ -29,6 +29,12 @@ TEST_CASE("list") { {"target", "", { {"value", PropertyTypeInt} }}, + {"other_origin", "", { + {"array", PropertyTypeArray, "other_target"} + }}, + {"other_target", "", { + {"value", PropertyTypeInt} + }}, }); auto r = Realm::get_shared_realm(config); @@ -226,6 +232,42 @@ TEST_CASE("list") { } } + SECTION("tables-of-interest are tracked properly for multiple source versions") { + auto other_origin = r->read_group()->get_table("class_other_origin"); + auto other_target = r->read_group()->get_table("class_other_target"); + + r->begin_transaction(); + other_target->add_empty_row(); + other_origin->add_empty_row(); + LinkViewRef lv2 = other_origin->get_linklist(0, 0); + lv2->add(0); + r->commit_transaction(); + + List lst2(r, *r->config().schema->find("other_origin"), lv2); + + // Add a callback for list1, advance the version, then add a + // callback for list2, so that the notifiers added at each source + // version have different tables watched for modifications + CollectionChangeIndices changes1, changes2; + auto token1 = lst.add_notification_callback([&](CollectionChangeIndices c, std::exception_ptr) { + changes1 = std::move(c); + }); + + r->begin_transaction(); r->commit_transaction(); + + auto token2 = lst2.add_notification_callback([&](CollectionChangeIndices c, std::exception_ptr) { + changes2 = std::move(c); + }); + + r->begin_transaction(); + target->set_int(0, 0, 10); + r->commit_transaction(); + advance_and_notify(*r); + + REQUIRE_INDICES(changes1.modifications, 0); + REQUIRE(changes2.empty()); + } + SECTION("modifications are reported for rows that are moved and then moved back in a second transaction") { auto token = require_change();