removed unused code

This commit is contained in:
Sascha Kühl 2025-07-18 13:32:43 +02:00
parent 9f7a0c8625
commit ee025ea49e
1 changed files with 1 additions and 85 deletions

View File

@ -155,18 +155,6 @@ private:
join_columns_collector join_columns_collector_{}; join_columns_collector join_columns_collector_{};
}; };
inline void dump(std::ostream &os, const std::shared_ptr<schema_node> &node) {
os << "node [" << node->name() << "] (" /*<< node->type_index().name()*/ << ")\n";
for (auto it = node->info().endpoint_begin(); it != node->info().endpoint_end(); ++it) {
os << " " << node->name() << "::" << it->second->field_name() << " (" << it->second->type_name() << ")";
if (it->second->foreign_endpoint()) {
os << " <---> " << it->second->node().name() << "::" << it->second->foreign_endpoint()->field_name() << " (" << it->second->foreign_endpoint()->type_name() << ")\n";
} else {
os << " -> " << it->second->node().type_index().name() << "\n";
}
}
}
template<typename Type> template<typename Type>
template<class CollectionType> template<class CollectionType>
void relation_completer<Type>::on_has_many(const char *id, CollectionType &, void relation_completer<Type>::on_has_many(const char *id, CollectionType &,
@ -199,7 +187,6 @@ void relation_completer<Type>::on_has_many(const char *id, CollectionType &,
nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint); nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
} else { } else {
// A relation table is necessary // A relation table is necessary
// } else if (const auto endpoint = nodes_.top()->info().find_relation_endpoint(typeid(relation_value_type)); endpoint == nodes_.top()->info().endpoint_end()) {
// Endpoint was not found. // Endpoint was not found.
// Always attach a many-to-many relation type. If later a // Always attach a many-to-many relation type. If later a
// belongs-to relation handles this relation, the many-to-many // belongs-to relation handles this relation, the many-to-many
@ -221,77 +208,7 @@ void relation_completer<Type>::on_has_many(const char *id, CollectionType &,
const auto foreign_value_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, foreign_node); const auto foreign_value_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, foreign_node);
result.value()->info_->register_relation_endpoint(typeid(value_type), foreign_value_endpoint); result.value()->info_->register_relation_endpoint(typeid(value_type), foreign_value_endpoint);
// dump( std::cout, nodes_.top() );
// dump( std::cout, result.value() );
// if (const auto detach_result = schema_.detach_node(foreign_node); !detach_result) {
// // Todo: throw internal error
// return;
// }
} }
// } else {
// if (const auto rit = foreign_node->info_->find_relation_endpoint(nodes_.top()->type_index());
// rit != foreign_node->info().endpoint_end()) {
// if (rit->second->is_belongs_to()) {
// rit->second->node_ = foreign_node;
// const auto localEndpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, nodes_.top());
// nodes_.top()->info_->register_relation_endpoint(nodes_.top()->type_index(), localEndpoint);
// link_relation_endpoints(localEndpoint, rit->second);
// } else {
// // Todo: throw internal error relation node has invalid type
// }
// } else {
// // Todo: throw internal error couldn't find relation node
// }
// }
// auto local_it = nodes_.top()->info().find_relation_endpoint(typeid(value_type));
// if (local_it == nodes_.top()->info().endpoint_end()) {
// const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, result.value());
// local_it = nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
// }
// auto foreign_it = result.value()->info().find_relation_endpoint(typeid(value_type));
// if (foreign_it == result.value()->info().endpoint_end()) {
// const auto foreign_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, nodes_.top());
// foreign_it = result.value()->info_->register_relation_endpoint(typeid(Type), foreign_endpoint);
// }
// link_relation_endpoints(local_it->second, foreign_it->second);
/*
if (const auto endpoint = nodes_.top()->info().find_relation_endpoint(typeid(relation_value_type)); endpoint == nodes_.top()->info().endpoint_end()) {
// Endpoint was not found
log_.debug("node '%s' has has many foreign keys '%s' mapped by '%s'", nodes_.top()->name().c_str(), id, join_column);
result = schema_node::make_relation_node<relation_value_type>(
schema_.schema(), id, [join_column] {
return std::make_unique<relation_value_type>("id", join_column);
});
if (!result) {
// Todo: throw internal error
return;
}
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, nodes_.top());
const auto foreign_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, result.value());
nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
foreign_endpoint->node_->info_->register_relation_endpoint(nodes_.top()->type_index(), foreign_endpoint);
link_relation_endpoints(local_endpoint, foreign_endpoint);
} else {
const auto &foreign_node = result.value();
if (const auto rit = foreign_node->info_->find_relation_endpoint(nodes_.top()->type_index());
rit != foreign_node->info().endpoint_end()) {
if (rit->second->is_belongs_to()) {
rit->second->node_ = foreign_node;
const auto localEndpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, nodes_.top());
nodes_.top()->info_->register_relation_endpoint(nodes_.top()->type_index(), localEndpoint);
link_relation_endpoints(localEndpoint, rit->second);
} else {
// Todo: throw internal error relation node has invalid type
}
} else {
// Todo: throw internal error couldn't find relation node
}
}
*/
} }
template<typename Type> template<typename Type>
@ -310,10 +227,9 @@ void relation_completer<Type>::on_has_many(const char *id, CollectionType &, con
if (!result) { if (!result) {
// Todo: throw internal exception // Todo: throw internal exception
return;
} }
// const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, nodes_.top());
// const auto foreign_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, result.value());
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, result.value()); const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, result.value());
const auto foreign_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, nodes_.top()); const auto foreign_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, nodes_.top());