Commit 65718c64 by Maarten L. Hekkelman

fix updating index for change in value in category

parent 6e30365f
Version 7.0.5
- Fix case where category index was not updated for updated value
Version 7.0.4 Version 7.0.4
- Do not install headers and library in case we're not the top project - Do not install headers and library in case we're not the top project
......
...@@ -1321,7 +1321,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie ...@@ -1321,7 +1321,7 @@ void category::update_value(const std::vector<row_handle> &rows, std::string_vie
std::string oldValue{ parent[item_name].text() }; std::string oldValue{ parent[item_name].text() };
std::string value{ value_provider(oldValue) }; std::string value{ value_provider(oldValue) };
parent.assign(colIx, value, false); update_value(parent.get_row(), colIx, value, false, false);
for (auto &&[childCat, linked] : m_child_links) for (auto &&[childCat, linked] : m_child_links)
{ {
...@@ -1444,8 +1444,7 @@ void category::update_value(row *row, uint16_t item, std::string_view value, boo ...@@ -1444,8 +1444,7 @@ void category::update_value(row *row, uint16_t item, std::string_view value, boo
// before updating // before updating
bool reinsert = false; bool reinsert = false;
if (updateLinked and // an update of an Item's value if (m_index != nullptr and key_item_indices().count(item))
m_index != nullptr and key_item_indices().count(item))
{ {
reinsert = m_index->find(*this, row); reinsert = m_index->find(*this, row);
if (reinsert) if (reinsert)
......
...@@ -2725,8 +2725,22 @@ void structure::cleanup_empty_categories() ...@@ -2725,8 +2725,22 @@ void structure::cleanup_empty_categories()
obsoleteEntities.push_back(entity); obsoleteEntities.push_back(entity);
} }
auto validator = m_db.get_validator();
for (auto entity : obsoleteEntities) for (auto entity : obsoleteEntities)
{
std::string entityID = entity["id"].as<std::string>();
if (validator)
{
for (auto linked : validator->get_links_for_parent("entity"))
{
if (auto cat = m_db.get(linked->m_child_category))
cat->erase(cif::key(linked->m_child_keys.front()) == entityID);
}
}
entities.erase(entity); entities.erase(entity);
}
// the rest? // the rest?
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment