builder progress (attribute, object and constraint class in todo.md)
This commit is contained in:
@@ -93,6 +93,23 @@ private:
|
||||
std::shared_ptr<attribute> reference_column_;
|
||||
};
|
||||
|
||||
|
||||
class object {
|
||||
public:
|
||||
using iterator = std::vector<attribute>::iterator;
|
||||
using const_iterator = std::vector<attribute>::const_iterator;
|
||||
|
||||
private:
|
||||
std::vector<attribute> columns_;
|
||||
std::string name_;
|
||||
std::string alias_;
|
||||
};
|
||||
|
||||
class constraint {
|
||||
public:
|
||||
private:
|
||||
std::shared_ptr<attribute> column_;
|
||||
};
|
||||
/**
|
||||
* User defined literal to have a shortcut creating a column object
|
||||
* @param name Name of the column
|
||||
|
||||
@@ -18,9 +18,9 @@ private:
|
||||
using node_ptr = std::shared_ptr<repository_node>;
|
||||
|
||||
public:
|
||||
explicit shadow_repository(object::repository& s);
|
||||
explicit shadow_repository(repository& s);
|
||||
|
||||
[[nodiscard]] object::repository& repo() const;
|
||||
[[nodiscard]] repository& repo() const;
|
||||
[[nodiscard]] bool contains(const std::type_index& ti) const;
|
||||
[[nodiscard]] utils::result<node_ptr, utils::error> find_node(const std::type_index &type_index) const;
|
||||
[[nodiscard]] utils::result<node_ptr, utils::error> find_node(const std::string &name) const;
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
[[nodiscard]] utils::result<void, utils::error> detach_node(const std::shared_ptr<repository_node> &node) const;
|
||||
|
||||
private:
|
||||
object::repository& schema_;
|
||||
repository& repo_;
|
||||
};
|
||||
}
|
||||
#endif //SHADOW_SCHEMA_HPP
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
template < typename Type >
|
||||
static std::shared_ptr<repository_node> make_node(repository& repo, const std::string& name) {
|
||||
auto node = std::shared_ptr<repository_node>(new repository_node(repo, name, typeid(Type)));
|
||||
auto node = std::make_shared<repository_node>( repo, name, typeid( Type ) );
|
||||
|
||||
primary_key_resolver resolver;
|
||||
auto pk_info = resolver.resolve<Type>();
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
void update_name(const std::string& name);
|
||||
|
||||
template <typename Type>
|
||||
object_info_ref<Type> info() const {
|
||||
[[nodiscard]] object_info_ref<Type> info() const {
|
||||
return std::ref(static_cast<const object_info<Type>&>(*info_));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "matador/utils/basic_types.hpp"
|
||||
#include "matador/utils/constraints.hpp"
|
||||
#include "matador/utils/data_type_traits.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -23,26 +24,25 @@ private:
|
||||
std::string alias_;
|
||||
};
|
||||
|
||||
// class attribute {
|
||||
// public:
|
||||
// attribute(std::string name, const utils::basic_type type)
|
||||
// : name_(std::move(name))
|
||||
// , type_(type) {}
|
||||
//
|
||||
// [[nodiscard]] const std::string& name() const;
|
||||
// [[nodiscard]] utils::basic_type type() const;
|
||||
// [[nodiscard]] const attribute_options& options() const;
|
||||
//
|
||||
// private:
|
||||
// friend class entity;
|
||||
//
|
||||
// std::string name_;
|
||||
// std::string alias_;
|
||||
// utils::basic_type type_{};
|
||||
// attribute_options options_;
|
||||
//
|
||||
// entity* owner_{nullptr};
|
||||
// };
|
||||
class data_type {
|
||||
public:
|
||||
template<typename Type>
|
||||
data_type() : type_(utils::data_type_traits<Type>()) {}
|
||||
template<typename Type>
|
||||
explicit data_type(const size_t size) : type_(utils::data_type_traits<Type>()), size_(size) {}
|
||||
|
||||
[[nodiscard]] const utils::basic_type& type() const { return type_; }
|
||||
[[nodiscard]] size_t size() const { return size_; }
|
||||
|
||||
private:
|
||||
utils::basic_type type_{};
|
||||
size_t size_{0};
|
||||
};
|
||||
|
||||
// using BigInt = data_type<int64_t>();
|
||||
// using Real = data_type<float>;
|
||||
// using double_ = data_type<double>;
|
||||
// using string = data_type<std::string>;
|
||||
|
||||
class constraint {
|
||||
public:
|
||||
@@ -70,13 +70,17 @@ namespace matador::query {
|
||||
|
||||
class column_builder {
|
||||
public:
|
||||
explicit column_builder(std::string column_name);
|
||||
explicit column_builder(std::string column_name, utils::basic_type type, size_t size = 0);
|
||||
|
||||
// ReSharper disable once CppNonExplicitConversionOperator
|
||||
operator query::column() const; // NOLINT(*-explicit-constructor)
|
||||
|
||||
column_builder& not_null();
|
||||
|
||||
private:
|
||||
std::string column_name;
|
||||
std::string column_name_;
|
||||
utils::basic_type type_{};
|
||||
utils::constraints constraints_{};
|
||||
};
|
||||
|
||||
class table_builder {
|
||||
@@ -113,7 +117,7 @@ private:
|
||||
|
||||
constraint_builder constraint(std::string name);
|
||||
table_builder table(std::string name);
|
||||
column_builder column(std::string name);
|
||||
column_builder column(std::string name, utils::basic_type type, size_t size = 0);
|
||||
|
||||
}
|
||||
#endif //MATADOR_BUILDER_HPP
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "matador/sql/sql_functions.hpp"
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
@@ -40,6 +39,7 @@ private:
|
||||
std::shared_ptr<query::table> table_;
|
||||
std::string name;
|
||||
std::string alias_;
|
||||
|
||||
sql::sql_function_t function_{sql::sql_function_t::None};
|
||||
};
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "matador/query/table.hpp"
|
||||
#include "matador/query/query_part.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace matador::query {
|
||||
|
||||
struct query_data {
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
#define QUERY_QUERY_DATA_HPP
|
||||
|
||||
#include "matador/object/attribute.hpp"
|
||||
#include "matador/query/table.hpp"
|
||||
|
||||
#include "matador/utils/types.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
enum class sql_command {
|
||||
|
||||
Reference in New Issue
Block a user