has many fetch with join

This commit is contained in:
Sascha Kühl
2025-02-19 14:51:42 +01:00
parent 784f6e768d
commit 8ab8274d93
19 changed files with 264 additions and 52 deletions
+43 -10
View File
@@ -1,5 +1,7 @@
#include "matador/sql/field.hpp"
#include "matador/utils/constraints.hpp"
#include <ostream>
namespace matador::sql {
@@ -9,23 +11,24 @@ field::field(std::string name)
, value_(nullptr)
{}
field::field(std::string name, const utils::basic_type dt, const size_t size, const int index)
: name_(std::move(name))
, index_(index)
, value_(dt, size) {}
field::field(std::string name, const utils::basic_type dt, const field_type type, const size_t size, const int index)
: name_(std::move(name))
, type_(type)
, index_(index)
, value_(dt, size) {}
field::field(field &&x) noexcept
: name_(std::move(x.name_))
, index_(x.index_)
, value_(std::move(x.value_))
{
: name_(std::move(x.name_))
, type_(x.type_)
, index_(x.index_)
, value_(std::move(x.value_)) {
x.value_ = nullptr;
x.index_ = -1;
}
field &field::operator=(field &&x) noexcept
{
field &field::operator=(field &&x) noexcept {
name_ = std::move(x.name_);
type_ = x.type_;
index_ = x.index_;
value_ = std::move(x.value_);
x.index_ = -1;
@@ -39,6 +42,10 @@ const std::string &field::name() const
return name_;
}
field_type field::type() const {
return type_;
}
size_t field::size() const
{
return value_.size();
@@ -55,6 +62,19 @@ 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("");
@@ -95,4 +115,17 @@ bool field::is_null() const
return value_.is_null();
}
bool field::is_primary_key() const {
return type_ == field_type::PrimaryKey;
}
bool field::is_foreign_key() const {
return type_ == field_type::ForeignKey;
}
bool field::is_attribute() const {
return type_ == field_type::Attribute;
}
}