fixed restriction and constraint class to use size_t
This commit is contained in:
@@ -25,7 +25,7 @@ const std::vector<attribute>& basic_object_info::attributes() const {
|
||||
return object_->attributes();
|
||||
}
|
||||
|
||||
const std::vector<class restriction>& basic_object_info::constraints() const {
|
||||
const std::list<restriction>& basic_object_info::constraints() const {
|
||||
return object_->constraints();
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ size_t object::constraint_count() const {
|
||||
return constraints_.size();
|
||||
}
|
||||
|
||||
const std::vector<restriction>& object::constraints() const {
|
||||
const std::list<restriction>& object::constraints() const {
|
||||
return constraints_;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ void object_generator::create_pk_constraint(const std::string &name) const {
|
||||
if (pk_attr == std::end(object_->attributes_)) {
|
||||
return;
|
||||
}
|
||||
restriction pk_constraint(*pk_attr);
|
||||
restriction pk_constraint(pk_attr->index());
|
||||
pk_constraint.options_ |= utils::constraints::PrimaryKey;
|
||||
pk_constraint.owner_ = object_;
|
||||
object_->constraints_.emplace_back(std::move(pk_constraint));
|
||||
@@ -41,7 +41,7 @@ void object_generator::create_unique_constraint(const std::string &name) const {
|
||||
if (pk_attr == std::end(object_->attributes_)) {
|
||||
return;
|
||||
}
|
||||
restriction pk_constraint(*pk_attr);
|
||||
restriction pk_constraint(pk_attr->index());
|
||||
pk_constraint.options_ |= utils::constraints::Unique;
|
||||
pk_constraint.owner_ = object_;
|
||||
}
|
||||
|
||||
@@ -4,16 +4,23 @@
|
||||
#include "matador/object/object.hpp"
|
||||
|
||||
namespace matador::object {
|
||||
restriction::restriction(const class attribute& attr)
|
||||
: attr_(attr) {}
|
||||
restriction::restriction(const size_t attr_index)
|
||||
: index_(attr_index) {}
|
||||
|
||||
const class attribute& restriction::attribute() const {
|
||||
return attr_;
|
||||
size_t restriction::attribute_index() const {
|
||||
return index_;
|
||||
}
|
||||
|
||||
std::string restriction::column_name() const {
|
||||
return attr_.name();
|
||||
const auto o = owner_.lock();
|
||||
return o ? o->attributes().at(index_).name() : "";
|
||||
}
|
||||
|
||||
utils::constraints restriction::options() const {
|
||||
const auto o = owner_.lock();
|
||||
return o ? o->attributes().at(index_).attributes().options() : utils::constraints::None;
|
||||
}
|
||||
|
||||
std::shared_ptr<object> restriction::owner() const {
|
||||
return owner_.lock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user