observer progress, added to schema and added schema_observer class
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "matador/query/criteria.hpp"
|
||||
#include "matador/query/query.hpp"
|
||||
#include "matador/query/schema.hpp"
|
||||
|
||||
#include "matador/sql/executor.hpp"
|
||||
#include "matador/sql/statement.hpp"
|
||||
@@ -33,7 +34,7 @@ struct entity_query_data {
|
||||
|
||||
class criteria_transformer final : public query::criteria_visitor {
|
||||
public:
|
||||
criteria_transformer(const object::repository &repo, const std::unordered_map<std::string, std::shared_ptr<query::table>>& tables_by_name);
|
||||
criteria_transformer(const query::schema &repo, const std::unordered_map<std::string, std::shared_ptr<query::table>>& tables_by_name);
|
||||
void visit( const query::between_criteria& node ) override;
|
||||
void visit( const query::binary_criteria& node ) override;
|
||||
void visit( const query::binary_column_criteria& node ) override;
|
||||
@@ -47,19 +48,19 @@ private:
|
||||
void update_criteria_column(const query::abstract_column_criteria& node) const;
|
||||
|
||||
private:
|
||||
const object::repository &repo_;
|
||||
const query::schema &repo_;
|
||||
const std::unordered_map<std::string, std::shared_ptr<query::table>>& tables_by_name_;
|
||||
};
|
||||
|
||||
class session_query_builder final {
|
||||
public:
|
||||
session_query_builder(const object::repository &scm, sql::executor &exec)
|
||||
session_query_builder(const query::schema &scm, sql::executor &exec)
|
||||
: schema_(scm)
|
||||
, executor_(exec){}
|
||||
|
||||
template<class EntityType>
|
||||
utils::result<entity_query_data, query_build_error> build(query::criteria_ptr clause = {}) {
|
||||
const auto info = schema_.info<EntityType>();
|
||||
const auto info = schema_.repo().info<EntityType>();
|
||||
if (!info) {
|
||||
return utils::failure(query_build_error::UnknownType);
|
||||
}
|
||||
@@ -114,7 +115,7 @@ public:
|
||||
template<class ContainerType>
|
||||
void on_has_many(const char * /*id*/, ContainerType &, const char *join_column, const utils::foreign_attributes &attr) {
|
||||
if (attr.fetch() == utils::fetch_type::Eager) {
|
||||
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||
const auto result = schema_.repo().basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||
if (!result) {
|
||||
throw query_builder_exception{query_build_error::UnknownType};
|
||||
}
|
||||
@@ -146,7 +147,7 @@ public:
|
||||
if (attr.fetch() != utils::fetch_type::Eager) {
|
||||
return;
|
||||
}
|
||||
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||
const auto result = schema_.repo().basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||
if (!result) {
|
||||
throw query_builder_exception{query_build_error::UnknownType};
|
||||
}
|
||||
@@ -186,7 +187,7 @@ public:
|
||||
if (attr.fetch() != utils::fetch_type::Eager) {
|
||||
return;
|
||||
}
|
||||
const auto result = schema_.basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||
const auto result = schema_.repo().basic_info(typeid(typename ContainerType::value_type::value_type));
|
||||
if (!result) {
|
||||
throw query_builder_exception{query_build_error::UnknownType};
|
||||
}
|
||||
@@ -239,7 +240,7 @@ private:
|
||||
|
||||
std::stack<table_info> table_info_stack_{};
|
||||
std::unordered_map<std::string, std::shared_ptr<query::table>> processed_tables_{};
|
||||
const object::repository &schema_;
|
||||
const query::schema &schema_;
|
||||
entity_query_data entity_query_data_{};
|
||||
unsigned int column_index{0};
|
||||
unsigned int table_index{0};
|
||||
@@ -249,7 +250,7 @@ private:
|
||||
|
||||
template<class Pointer>
|
||||
void session_query_builder::on_foreign_object(const char *id, Pointer &, const utils::foreign_attributes &attr) {
|
||||
const auto info = schema_.info<typename Pointer::value_type>();
|
||||
const auto info = schema_.repo().info<typename Pointer::value_type>();
|
||||
if (!info) {
|
||||
throw query_builder_exception{query_build_error::UnknownType};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user