67 lines
2.0 KiB
C++
67 lines
2.0 KiB
C++
#include "matador/query/table_constraint.hpp"
|
|
|
|
#include "matador/utils/constraints.hpp"
|
|
|
|
namespace matador::query {
|
|
table_constraint::table_constraint(std::string column_name, std::string table_name, utils::constraints type)
|
|
: column_name_(std::move(column_name))
|
|
, table_name_(std::move(table_name))
|
|
, type_(type) {}
|
|
|
|
table_constraint::table_constraint(std::string column_name, std::string table_name, utils::constraints type, std::string referenced_table, std::string referenced_column)
|
|
: column_name_(std::move(column_name))
|
|
, table_name_(std::move(table_name))
|
|
, type_(type)
|
|
, referenced_table_(std::move(referenced_table))
|
|
, referenced_column_(std::move(referenced_column)) {}
|
|
|
|
table_constraint::table_constraint(std::string name,
|
|
std::string column_name,
|
|
std::string table_name,
|
|
utils::constraints type,
|
|
std::string referenced_table,
|
|
std::string referenced_column)
|
|
: name_(std::move(name))
|
|
, column_name_(std::move(column_name))
|
|
, table_name_(std::move(table_name))
|
|
, type_(type)
|
|
, referenced_table_(std::move(referenced_table))
|
|
, referenced_column_(std::move(referenced_column)) {}
|
|
|
|
std::string table_constraint::name() const {
|
|
return name_;
|
|
}
|
|
|
|
std::string table_constraint::column_name() const {
|
|
return column_name_;
|
|
}
|
|
|
|
std::string table_constraint::table_name() const {
|
|
return table_name_;
|
|
}
|
|
|
|
const utils::constraints& table_constraint::type() const {
|
|
return type_;
|
|
}
|
|
|
|
bool table_constraint::is_primary_key_constraint() const {
|
|
return utils::is_constraint_set(type_, utils::constraints::PrimaryKey);
|
|
}
|
|
|
|
bool table_constraint::is_foreign_key_constraint() const {
|
|
return utils::is_constraint_set(type_, utils::constraints::ForeignKey);
|
|
}
|
|
|
|
bool table_constraint::is_unique_constraint() const {
|
|
return utils::is_constraint_set(type_, utils::constraints::Unique);
|
|
}
|
|
|
|
const std::string& table_constraint::referenced_table() const {
|
|
return referenced_table_;
|
|
}
|
|
|
|
const std::string& table_constraint::referenced_column() const {
|
|
return referenced_column_;
|
|
}
|
|
}
|