fixed object generation on nested objects
This commit is contained in:
@@ -35,19 +35,6 @@ void object_generator::create_pk_constraint(const std::string& name) const {
|
||||
object_->constraints_.emplace_back(std::move(pk_constraint));
|
||||
}
|
||||
|
||||
void object_generator::create_fk_constraint(const std::type_index& ti, const std::string& name) const {
|
||||
const auto pk_attr = find_attribute_by_name(name);
|
||||
if (pk_attr == std::end(object_->attributes_)) {
|
||||
return;
|
||||
}
|
||||
const auto obj = fk_object(ti);
|
||||
restriction pk_constraint(*pk_attr);
|
||||
pk_constraint.options_ |= utils::constraints::ForeignKey;
|
||||
pk_constraint.owner_ = object_;
|
||||
pk_constraint.reference_ = obj;
|
||||
object_->constraints_.emplace_back(std::move(pk_constraint));
|
||||
}
|
||||
|
||||
void object_generator::create_unique_constraint(const std::string& name) const {
|
||||
const auto pk_attr = find_attribute_by_name(name);
|
||||
if (pk_attr == std::end(object_->attributes_)) {
|
||||
@@ -68,16 +55,4 @@ void object_generator::prepare_primary_key(attribute& ref, utils::identifier &&p
|
||||
object_->pk_attribute_ = &ref;
|
||||
object_->pk_identifier_ = std::move(pk);
|
||||
}
|
||||
|
||||
std::shared_ptr<object> object_generator::fk_object(const std::type_index& ti) const {
|
||||
const auto result = repo_.basic_info(ti);
|
||||
if (result) {
|
||||
return result->get().object();
|
||||
}
|
||||
|
||||
if (repo_.has_object_for_type(ti)) {
|
||||
return repo_.object_for_type(ti);
|
||||
}
|
||||
return repo_.provide_object_in_advance(ti, std::make_shared<object>(""));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user