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

Je/rcore 368 #4167

Merged
merged 4 commits into from
Dec 18, 2020
Merged

Je/rcore 368 #4167

merged 4 commits into from
Dec 18, 2020

Conversation

jedelbo
Copy link
Contributor

@jedelbo jedelbo commented Dec 4, 2020

What, How & Why?

Related to #4010

☑️ ToDos

  • 📝 Changelog update
  • 🚦 Tests (or not relevant)

@jedelbo jedelbo changed the base branch from develop to master December 4, 2020 14:15
@jedelbo
Copy link
Contributor Author

jedelbo commented Dec 4, 2020

@tgoyne how would you suggest this should be fixed? As I can see it, CollectionChangeBuilder::calculate() does not have enough information to find out that an object has been deleted and then re-created.

Comment on lines 135 to 142
if (m_info->tables.count(table_key.value)) {
auto& changes = m_info->tables[table_key.value];
for (auto& key_val : m_previous_rows) {
if (changes.get_deletions().count(key_val)) {
key_val = -1;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (m_info->tables.count(table_key.value)) {
auto& changes = m_info->tables[table_key.value];
for (auto& key_val : m_previous_rows) {
if (changes.get_deletions().count(key_val)) {
key_val = -1;
}
}
}
if (auto it = m_info->tables.find(table_key.value); it != m_info->tables.end()) {
auto& changes = *it;
for (auto& key_val : m_previous_rows) {
if (changes.deletions_contains(key_val)) {
key_val = -1;
}
}
}

Checking get_deletions() does the wrong thing for a table clear, and using find() eliminates a double lookup in the set (which probably doesn't matter much...). This does point out that we also need to test table clear followed by creating an object with one of the deleted PKs (and resolve the FIXME in deletions_contains() by changing the check on insertions to return true).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out that "clear_table" is no longer issued. We will have a deletion instruction for every object. So that code is removed.

@@ -3525,3 +3525,88 @@ TEST_CASE("results: query helpers", "[include]") {
CHECK(includes.get_description(table) == "INCLUDE(@links.class_linking_object.link)");
}
}

TEST_CASE("notifications: objects with PK recreated") {
Copy link
Member

Choose a reason for hiding this comment

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

This is a lot of duplicated code. The test should just be another section in the existing test case rather than copying and pasting all the setup.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the setup is different.

@jedelbo jedelbo requested a review from tgoyne December 10, 2020 08:37
@jedelbo
Copy link
Contributor Author

jedelbo commented Dec 14, 2020

@tgoyne Any more comments?

@jedelbo jedelbo requested a review from ironage December 15, 2020 15:51
@jedelbo
Copy link
Contributor Author

jedelbo commented Dec 15, 2020

@ironage I take the fact that @tgoyne has no more comments as an implicit approval. Can you make an explicit one?

r->read_group().get_table("class_string_pk")->remove_object(k3);
create("no_pk", AnyDict{{"id", INT64_C(123)}, {"value", INT64_C(200)}});
create("int_pk", AnyDict{{"id", INT64_C(456)}, {"value", INT64_C(200)}});
create("string_pk", AnyDict{{"id", std::string("hello")}, {"value", INT64_C(200)}});
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the expected notification changes for this event? Can you add a check that this is being observed as CollectionChangeSet::modifications and not a deletion and insertion? at least I think that is the expected behaviour, except for maybe the no_pk case where we don't guarantee reuse of auto generated pks?

Copy link
Member

Choose a reason for hiding this comment

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

This should be reported as a delete and insert. All of these tests need to be validating the changeset and not just that a notification was sent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test is now enhanced with those tests.

Copy link
Contributor

@ironage ironage left a comment

Choose a reason for hiding this comment

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

LGTM

@jedelbo jedelbo merged commit 9ae2cb5 into master Dec 18, 2020
@jedelbo jedelbo deleted the je/rcore-368 branch December 18, 2020 09:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants