removed string from restriction

This commit is contained in:
2025-12-09 21:13:47 +01:00
parent c4f8731262
commit 9b7b74524f
13 changed files with 86 additions and 166 deletions
+41 -40
View File
@@ -1,6 +1,7 @@
#include "matador/object/restriction.hpp"
#include "matador/object/attribute.hpp"
#include "matador/object/object.hpp"
namespace matador::object {
restriction::restriction(std::string name)
@@ -46,11 +47,11 @@ bool restriction::is_unique_constraint() const {
}
const std::string& restriction::ref_table_name() const {
return ref_table_name_;
return reference_->name();
}
const std::string& restriction::ref_column_name() const {
return ref_column_name_;
return reference_->primary_key_attribute()->name();
}
std::ostream & operator<<(std::ostream &os, const class restriction &c) {
@@ -58,42 +59,42 @@ std::ostream & operator<<(std::ostream &os, const class restriction &c) {
return os;
}
constraint_builder & constraint_builder::constraint(std::string name) {
constraint_name = std::move(name);
return *this;
}
constraint_builder & constraint_builder::primary_key(std::string name) {
column_name = std::move(name);
options_ |= utils::constraints::PrimaryKey;
return *this;
}
constraint_builder & constraint_builder::foreign_key(std::string name) {
column_name = std::move(name);
options_ |= utils::constraints::ForeignKey;
return *this;
}
constraint_builder & constraint_builder::references(std::string table, std::string column) {
ref_table_name = std::move(table);
ref_column_name = std::move(column);
return *this;
}
constraint_builder::operator class restriction() const {
class restriction c;
c.name_ = constraint_name;
c.attr_ = column_name;
c.options_ = options_;
c.ref_column_name_ = ref_column_name;
c.ref_table_name_ = ref_table_name;
return c;
}
constraint_builder constraint(std::string name) {
constraint_builder builder;
return builder.constraint(std::move(name));
}
// constraint_builder & constraint_builder::constraint(std::string name) {
// constraint_name = std::move(name);
// return *this;
// }
//
// constraint_builder & constraint_builder::primary_key(std::string name) {
// column_name = std::move(name);
// options_ |= utils::constraints::PrimaryKey;
// return *this;
// }
//
// constraint_builder & constraint_builder::foreign_key(std::string name) {
// column_name = std::move(name);
// options_ |= utils::constraints::ForeignKey;
// return *this;
// }
//
// constraint_builder & constraint_builder::references(std::string table, std::string column) {
// ref_table_name = std::move(table);
// ref_column_name = std::move(column);
//
// return *this;
// }
//
// constraint_builder::operator class restriction() const {
// class restriction c;
// c.name_ = constraint_name;
// c.attr_ = column_name;
// c.options_ = options_;
// c.ref_column_name_ = ref_column_name;
// c.ref_table_name_ = ref_table_name;
// return c;
// }
//
// constraint_builder constraint(std::string name) {
// constraint_builder builder;
// return builder.constraint(std::move(name));
// }
}