Fix tracking of which tables need change info with multiple source notifier versions
This commit is contained in:
parent
ea3a2f4711
commit
238e9e3b6b
|
@ -338,8 +338,10 @@ public:
|
||||||
{
|
{
|
||||||
if (version != m_sg.get_version_of_current_transaction()) {
|
if (version != m_sg.get_version_of_current_transaction()) {
|
||||||
transaction::advance(m_sg, *m_current, version);
|
transaction::advance(m_sg, *m_current, version);
|
||||||
// FIXME: needs to copy tables to watch?
|
m_info.push_back({
|
||||||
m_info.push_back({{}, {}, std::move(m_current->lists)});
|
m_current->table_modifications_needed,
|
||||||
|
m_current->table_moves_needed,
|
||||||
|
std::move(m_current->lists)});
|
||||||
m_current = &m_info.back();
|
m_current = &m_info.back();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,12 @@ TEST_CASE("list") {
|
||||||
{"target", "", {
|
{"target", "", {
|
||||||
{"value", PropertyTypeInt}
|
{"value", PropertyTypeInt}
|
||||||
}},
|
}},
|
||||||
|
{"other_origin", "", {
|
||||||
|
{"array", PropertyTypeArray, "other_target"}
|
||||||
|
}},
|
||||||
|
{"other_target", "", {
|
||||||
|
{"value", PropertyTypeInt}
|
||||||
|
}},
|
||||||
});
|
});
|
||||||
|
|
||||||
auto r = Realm::get_shared_realm(config);
|
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") {
|
SECTION("modifications are reported for rows that are moved and then moved back in a second transaction") {
|
||||||
auto token = require_change();
|
auto token = require_change();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue