fixed some repository-related tests
This commit is contained in:
@@ -68,11 +68,11 @@ private:
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
void attach_node() {
|
||||
void attach_node(const std::string &name = "") {
|
||||
if (repo_.contains(typeid(Type))) {
|
||||
return;
|
||||
}
|
||||
const auto node = repository_node::make_node<Type>(repo_.repo(), "");
|
||||
const auto node = repository_node::make_node<Type>(repo_.repo(), name);
|
||||
if (auto result = repo_.attach_node(node)) {
|
||||
complete<Type>(result.value());
|
||||
}
|
||||
@@ -101,13 +101,13 @@ void foreign_node_completer::on_has_many( const char* /*id*/, CollectionType&, c
|
||||
}
|
||||
|
||||
template<class CollectionType>
|
||||
void foreign_node_completer::on_has_many_to_many( const char* /*id*/, CollectionType& /*collection*/, const char* /*join_column*/, const char* /*inverse_join_column*/, const utils::foreign_attributes& /*attr*/ ) {
|
||||
attach_node<typename CollectionType::value_type::value_type>();
|
||||
void foreign_node_completer::on_has_many_to_many( const char* id, CollectionType& /*collection*/, const char* /*join_column*/, const char* /*inverse_join_column*/, const utils::foreign_attributes& /*attr*/ ) {
|
||||
attach_node<typename CollectionType::value_type::value_type>(/*id*/);
|
||||
}
|
||||
|
||||
template<class CollectionType>
|
||||
void foreign_node_completer::on_has_many_to_many( const char* /*id*/, CollectionType& /*collection*/, const utils::foreign_attributes& /*attr*/ ) {
|
||||
attach_node<typename CollectionType::value_type::value_type>();
|
||||
void foreign_node_completer::on_has_many_to_many( const char* id, CollectionType& /*collection*/, const utils::foreign_attributes& /*attr*/ ) {
|
||||
attach_node<typename CollectionType::value_type::value_type>(/*id*/);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ public:
|
||||
} else if (!has_node(name)) {
|
||||
it->second->update_name(name);
|
||||
nodes_by_name_[name] = it->second;
|
||||
if (const auto i = nodes_by_name_.find(""); i != nodes_by_name_.end()) {
|
||||
nodes_by_name_.erase(i);
|
||||
}
|
||||
relation_completer<Type>::complete(it->second);
|
||||
log_.info("attach: update node name to '%s' (type: %s)", it->second->name().c_str(), it->second->type_index().name());
|
||||
} else {
|
||||
@@ -135,6 +138,8 @@ public:
|
||||
return utils::ok(result.value()->info<Type>());
|
||||
}
|
||||
|
||||
[[nodiscard]] utils::result<basic_object_info_ref, utils::error> basic_info(const std::string &name) const;
|
||||
|
||||
template<typename Type>
|
||||
[[nodiscard]] utils::result<basic_object_info_ref, utils::error> basic_info() const {
|
||||
auto result = find_node(std::type_index(typeid(Type)));
|
||||
|
||||
Reference in New Issue
Block a user