object generation progress

This commit is contained in:
Sascha Kühl
2025-12-10 17:05:24 +01:00
parent 9b7b74524f
commit 5afb616205
9 changed files with 59 additions and 45 deletions
+11 -24
View File
@@ -1,9 +1,10 @@
#include "matador/object/object.hpp"
namespace matador::object {
object::object( std::string name, std::string alias )
: name_(std::move(name))
, alias_(std::move(alias)) {}
object::object(std::string name)
: name_(std::move(name)) {
int i = 9;
}
const attribute& object::create_attribute(std::string name, const std::shared_ptr<object>& obj) {
attribute attr{std::move(name)};
@@ -11,16 +12,6 @@ const attribute& object::create_attribute(std::string name, const std::shared_pt
return obj->attributes_.emplace_back(std::move(attr));
}
// void object::add_attribute( attribute attr ) {
// auto &ref = attributes_.emplace_back(std::move(attr));
// ref.owner_ = this;
// }
//
// void object::add_constraint( class constraint c ) {
// auto &ref = constraints_.emplace_back(std::move(c));
// ref.owner_ = this;
// }
attribute* object::primary_key_attribute() const {
return pk_attribute_;
}
@@ -37,19 +28,15 @@ const std::string& object::name() const {
return name_;
}
const std::string& object::alias() const {
return alias_;
}
void object::update_name(const std::string& name) {
name_ = name;
for (auto& con : constraints_) {
if (con.is_primary_key_constraint()) {
con.name_ += name;
} else if (con.is_foreign_key_constraint()) {
con.name_ = "FK_" + name + "_" + con.column_name();
}
}
// for (auto& con : constraints_) {
// if (con.is_primary_key_constraint()) {
// con.name_ += name;
// } else if (con.is_foreign_key_constraint()) {
// con.name_ = "FK_" + name + "_" + con.column_name();
// }
// }
}
bool object::has_attributes() const {