removed string from restriction
This commit is contained in:
@@ -14,7 +14,7 @@ void object_generator::on_revision(const char* id, uint64_t& rev) {
|
||||
}
|
||||
|
||||
void object_generator::create_pk_constraint(const std::string& name) const {
|
||||
class restriction pk_constraint("PK_" + object_->name());
|
||||
restriction pk_constraint("PK_" + object_->name());
|
||||
pk_constraint.options_ |= utils::constraints::PrimaryKey;
|
||||
if (const auto pk_attr = find_attribute_by_name(name); pk_attr != std::end(object_->attributes_)) {
|
||||
pk_constraint.attr_ = &*pk_attr;
|
||||
@@ -25,23 +25,18 @@ void object_generator::create_pk_constraint(const std::string& name) const {
|
||||
|
||||
void object_generator::create_fk_constraint(const std::type_index& ti, const std::string& name) const {
|
||||
const auto obj = fk_object(ti);
|
||||
const auto *pk_attribute = obj->primary_key_attribute();
|
||||
class restriction pk_constraint("FK_" + object_->name() + "_" + name);
|
||||
restriction pk_constraint("FK_" + object_->name() + "_" + name);
|
||||
pk_constraint.options_ |= utils::constraints::ForeignKey;
|
||||
if (const auto pk_attr = find_attribute_by_name(name); pk_attr != std::end(object_->attributes_)) {
|
||||
pk_constraint.attr_ = &*pk_attr;
|
||||
}
|
||||
pk_constraint.owner_ = object_;
|
||||
pk_constraint.reference_ = obj;
|
||||
if (pk_attribute) {
|
||||
pk_constraint.ref_column_name_ = pk_attribute->name();
|
||||
pk_constraint.ref_table_name_ = pk_attribute->owner() ? pk_attribute->owner()->name() : "";
|
||||
}
|
||||
object_->constraints_.emplace_back(std::move(pk_constraint));
|
||||
}
|
||||
|
||||
void object_generator::create_unique_constraint(const std::string& name) const {
|
||||
class restriction pk_constraint("UK_" + object_->name() + "_" + name);
|
||||
restriction pk_constraint("UK_" + object_->name() + "_" + name);
|
||||
pk_constraint.options_ |= utils::constraints::Unique;
|
||||
if (const auto pk_attr = find_attribute_by_name(name); pk_attr != std::end(object_->attributes_)) {
|
||||
pk_constraint.attr_ = &*pk_attr;
|
||||
|
||||
Reference in New Issue
Block a user