attribute_definition and object_definition progress

This commit is contained in:
Sascha Kühl
2025-11-17 15:58:09 +01:00
parent 9ffcee1317
commit 7242dc2612
17 changed files with 161 additions and 205 deletions
+5 -20
View File
@@ -1,7 +1,5 @@
#include "matador/sql/field.hpp"
#include "matador/utils/constraints.hpp"
#include <ostream>
namespace matador::sql {
@@ -11,7 +9,7 @@ field::field(std::string name)
, value_(nullptr)
{}
field::field(std::string name, const utils::basic_type dt, const field_type type, const size_t size, const int index)
field::field(std::string name, const utils::basic_type dt, const utils::constraints type, const size_t size, const int index)
: name_(std::move(name))
, type_(type)
, index_(index)
@@ -42,7 +40,7 @@ const std::string &field::name() const
return name_;
}
field_type field::type() const {
utils::constraints field::type() const {
return type_;
}
@@ -62,19 +60,6 @@ std::ostream &operator<<(std::ostream &out, const field &col)
return out;
}
utils::constraints field::determine_constraint(const field_type type) {
switch (type) {
case field_type::PrimaryKey:
return utils::constraints::PRIMARY_KEY;
case field_type::ForeignKey:
return utils::constraints::FOREIGN_KEY;
case field_type::Attribute:
default:
return utils::constraints::NONE;
}
}
std::string field::str() const
{
return as<std::string>().value_or("");
@@ -116,15 +101,15 @@ bool field::is_null() const
}
bool field::is_primary_key() const {
return type_ == field_type::PrimaryKey;
return type_ == utils::constraints::PRIMARY_KEY;
}
bool field::is_foreign_key() const {
return type_ == field_type::ForeignKey;
return type_ == utils::constraints::FOREIGN_KEY;
}
bool field::is_attribute() const {
return type_ == field_type::Attribute;
return !is_primary_key() && !is_foreign_key();
}
+1 -11
View File
@@ -5,16 +5,6 @@
namespace matador::sql::detail {
field_type determine_field_type(const utils::constraints c) {
if (is_constraint_set(c, utils::constraints::FOREIGN_KEY)) {
return field_type::ForeignKey;
}
if (is_constraint_set(c, utils::constraints::PRIMARY_KEY)) {
return field_type::PrimaryKey;
}
return field_type::Attribute;
}
template<>
record *create_prototype<record>(const std::vector<object::attribute_definition> &prototype) {
auto result = std::make_unique<record>();
@@ -22,7 +12,7 @@ record *create_prototype<record>(const std::vector<object::attribute_definition>
result->append({
col.name(),
col.type(),
determine_field_type(col.attributes().options()),
col.attributes().options(),
col.attributes().size(),
col.index()
});