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
+21 -3
View File
@@ -8,8 +8,17 @@
#include <optional>
#include <string>
namespace matador::utils {
enum class constraints : unsigned char;
}
namespace matador::sql {
enum struct field_type {
Attribute,
PrimaryKey,
ForeignKey
};
/**
*
*/
@@ -17,11 +26,12 @@ class field {
public:
explicit field(std::string name);
template<typename Type>
field(std::string name, Type value, const size_t size = 0, const int index = -1)
field(std::string name, Type value, const field_type type = field_type::Attribute, const size_t size = 0, const int index = -1)
: name_(std::move(name))
, type_(type)
, index_(index)
, value_(value, size) {}
field(std::string name, utils::basic_type dt, size_t size = 0, int index = -1);
field(std::string name, utils::basic_type dt, field_type type = field_type::Attribute, size_t size = 0, int index = -1);
field(const field &x) = default;
field& operator=(const field &x) = default;
field(field &&x) noexcept;
@@ -35,6 +45,7 @@ public:
}
[[nodiscard]] const std::string& name() const;
[[nodiscard]] field_type type() const;
[[nodiscard]] size_t size() const;
[[nodiscard]] int index() const;
@@ -53,18 +64,25 @@ public:
[[nodiscard]] bool is_blob() const;
[[nodiscard]] bool is_null() const;
[[nodiscard]] bool is_primary_key() const;
[[nodiscard]] bool is_foreign_key() const;
[[nodiscard]] bool is_attribute() const;
friend std::ostream& operator<<(std::ostream &out, const field &col);
private:
static utils::constraints determine_constraint(field_type type);
template<class Operator>
void process(Operator &op) {
op.on_attribute(name_.c_str(), value_, value_.size());
op.on_attribute(name_.c_str(), value_, { value_.size(), determine_constraint(type_) } );
}
private:
friend class record;
std::string name_;
field_type type_{field_type::Attribute};
int index_{-1};
utils::value value_;