schema creation progress
This commit is contained in:
@@ -177,13 +177,13 @@ void relation_completer<Type>::on_has_many(const char *id, CollectionType &,
|
||||
if (const auto it = foreign_node->info_->find_relation_endpoint(typeid(Type)); it != foreign_node->info().endpoint_end()) {
|
||||
// corresponding belongs_to is available and was called (has_many <-> belongs_to)
|
||||
// complete the relation
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, foreign_node);
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasMany, foreign_node);
|
||||
nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
|
||||
link_relation_endpoints(local_endpoint, it->second);
|
||||
} else if (join_column_finder::has_join_column<value_type>(join_column)) {
|
||||
// corresponding belongs_to is available but was not called (has_many <-> belongs_to)
|
||||
// prepare the relation
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, foreign_node);
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasMany, foreign_node);
|
||||
nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
|
||||
} else {
|
||||
// A relation table is necessary
|
||||
@@ -200,13 +200,13 @@ void relation_completer<Type>::on_has_many(const char *id, CollectionType &,
|
||||
// Todo: throw internal error
|
||||
return;
|
||||
}
|
||||
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>("id", relation_type::BELONGS_TO, nodes_.top());
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasMany, result.value());
|
||||
const auto foreign_endpoint = std::make_shared<relation_endpoint>("id", relation_type::BelongsTo, nodes_.top());
|
||||
nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
|
||||
result.value()->info_->register_relation_endpoint(nodes_.top()->type_index(), foreign_endpoint);
|
||||
link_relation_endpoints(local_endpoint, foreign_endpoint);
|
||||
|
||||
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::BelongsTo, foreign_node);
|
||||
result.value()->info_->register_relation_endpoint(typeid(value_type), foreign_value_endpoint);
|
||||
}
|
||||
}
|
||||
@@ -230,8 +230,8 @@ void relation_completer<Type>::on_has_many(const char *id, CollectionType &, con
|
||||
return;
|
||||
}
|
||||
|
||||
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 local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasMany, result.value());
|
||||
const auto foreign_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BelongsTo, nodes_.top());
|
||||
|
||||
nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
|
||||
result.value()->info_->register_relation_endpoint(nodes_.top()->type_index(), foreign_endpoint);
|
||||
@@ -272,10 +272,10 @@ void relation_completer<Type>::on_has_many_to_many(const char *id,
|
||||
}
|
||||
|
||||
auto& node = result.value();
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, node);
|
||||
const auto join_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BELONGS_TO, nodes_.top());
|
||||
const auto inverse_join_endpoint = std::make_shared<relation_endpoint>(inverse_join_column, relation_type::BELONGS_TO, foreign_node);
|
||||
const auto foreign_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HAS_MANY, node);
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasMany, node);
|
||||
const auto join_endpoint = std::make_shared<relation_endpoint>(join_column, relation_type::BelongsTo, nodes_.top());
|
||||
const auto inverse_join_endpoint = std::make_shared<relation_endpoint>(inverse_join_column, relation_type::BelongsTo, foreign_node);
|
||||
const auto foreign_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasMany, node);
|
||||
// register relation endpoint in local node
|
||||
nodes_.top()->info_->register_relation_endpoint(typeid(typename CollectionType::value_type::value_type), local_endpoint);
|
||||
// register relation endpoint in foreign node
|
||||
@@ -318,7 +318,7 @@ void relation_completer<Type>::on_has_one(const char *id,
|
||||
|
||||
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_ONE, result.value());
|
||||
const auto local_endpoint = std::make_shared<relation_endpoint>(id, relation_type::HasOne, result.value());
|
||||
local_it = nodes_.top()->info_->register_relation_endpoint(typeid(value_type), local_endpoint);
|
||||
}
|
||||
if (const auto foreign_it = result.value()->info().find_relation_endpoint(typeid(Type)); foreign_it != result.value()->info().endpoint_end()) {
|
||||
@@ -346,11 +346,11 @@ void relation_completer<Type>::on_belongs_to(const char *id,
|
||||
if (const auto it = foreign_node->info_->find_relation_endpoint(nodes_.top()->type_index()); it != foreign_node->info().endpoint_end()) {
|
||||
// Found corresponding relation endpoint in the foreign node
|
||||
if (it->second->is_has_one()) {
|
||||
const auto endpoint = std::make_shared<relation_endpoint>(id, relation_type::BELONGS_TO, foreign_node);
|
||||
const auto endpoint = std::make_shared<relation_endpoint>(id, relation_type::BelongsTo, foreign_node);
|
||||
nodes_.top()->info_->register_relation_endpoint(ti, endpoint);
|
||||
link_relation_endpoints(endpoint, it->second);
|
||||
} else if (it->second->is_has_many()) {
|
||||
const auto endpoint = std::make_shared<relation_endpoint>(id, relation_type::BELONGS_TO, foreign_node);
|
||||
const auto endpoint = std::make_shared<relation_endpoint>(id, relation_type::BelongsTo, foreign_node);
|
||||
nodes_.top()->info_->register_relation_endpoint(ti, endpoint);
|
||||
link_relation_endpoints(endpoint, it->second);
|
||||
} else if (it->second->foreign_endpoint()->node().type_index() == typeid(many_to_many_relation<Type, value_type>)) {
|
||||
@@ -368,7 +368,7 @@ void relation_completer<Type>::on_belongs_to(const char *id,
|
||||
}
|
||||
} else {
|
||||
// Relation node was not found, create only endpoint.
|
||||
const auto endpoint = std::make_shared<relation_endpoint>(id, relation_type::BELONGS_TO, foreign_node);
|
||||
const auto endpoint = std::make_shared<relation_endpoint>(id, relation_type::BelongsTo, foreign_node);
|
||||
nodes_.top()->info_->register_relation_endpoint(ti, endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user