query collection resolver producer progress
This commit is contained in:
parent
623a64b610
commit
ac514c3765
|
|
@ -37,6 +37,26 @@ private:
|
||||||
std::string pk_name_;
|
std::string pk_name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
class query_collection_resolver_producer : public sql::resolver_producer {
|
||||||
|
public:
|
||||||
|
query_collection_resolver_producer() = default;
|
||||||
|
query_collection_resolver_producer(const basic_schema& repo, const table& tab, std::string pk_name)
|
||||||
|
: resolver_producer(typeid(Type))
|
||||||
|
, repo_(repo)
|
||||||
|
, table_(tab)
|
||||||
|
, pk_name_(std::move(pk_name)) {}
|
||||||
|
|
||||||
|
std::shared_ptr<object::abstract_type_resolver> produce(sql::executor &exec) override {
|
||||||
|
return std::make_shared<query_object_resolver<Type>>(repo_, exec, table_, std::move(pk_name_));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const basic_schema& repo_;
|
||||||
|
const table& table_;
|
||||||
|
std::string pk_name_;
|
||||||
|
};
|
||||||
|
|
||||||
class schema;
|
class schema;
|
||||||
|
|
||||||
using schema_ref = std::reference_wrapper<schema>;
|
using schema_ref = std::reference_wrapper<schema>;
|
||||||
|
|
@ -144,6 +164,37 @@ utils::result<void, utils::error> schema::drop_table(const sql::connection &conn
|
||||||
|
|
||||||
return utils::failure(info.err());
|
return utils::failure(info.err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class producer_creator final {
|
||||||
|
public:
|
||||||
|
template<typename ValueType>
|
||||||
|
void on_primary_key(const char *id, ValueType &value, const utils::primary_key_attribute& attr = utils::default_pk_attributes) {
|
||||||
|
|
||||||
|
}
|
||||||
|
static void on_revision(const char * /*id*/, uint64_t &/*rev*/) {}
|
||||||
|
template<class Type>
|
||||||
|
static void on_attribute(const char * /*id*/, Type &/*value*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
|
||||||
|
template<class Pointer>
|
||||||
|
void on_belongs_to(const char * /*id*/, Pointer &x, const utils::foreign_attributes &attr) {}
|
||||||
|
template<class Pointer>
|
||||||
|
void on_has_one(const char * /*id*/, Pointer &x, const utils::foreign_attributes &attr) {}
|
||||||
|
template<class ContainerType>
|
||||||
|
void on_has_many_to_many(const char *, ContainerType &, const char * /*join_column*/, const char * /*inverse_join_column*/, const utils::foreign_attributes &attr) {}
|
||||||
|
template<class ContainerType>
|
||||||
|
void on_has_many_to_many(const char *, ContainerType &, const utils::foreign_attributes &attr) {}
|
||||||
|
|
||||||
|
template<class CollectionType>
|
||||||
|
void on_has_many(const char * /*id*/, CollectionType &cont, const char * /*join_column*/, const utils::foreign_attributes &attr, std::enable_if_t<object::is_object_ptr<typename CollectionType::value_type>::value> * = nullptr) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class CollectionType>
|
||||||
|
void on_has_many(const char * /*id*/, CollectionType &cont, const char * /*join_column*/, const utils::foreign_attributes &attr, std::enable_if_t<!object::is_object_ptr<typename CollectionType::value_type>::value> * = nullptr) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
void schema_observer<Type>::on_attach(const object::repository_node &node, const Type &/*prototype*/) const {
|
void schema_observer<Type>::on_attach(const object::repository_node &node, const Type &/*prototype*/) const {
|
||||||
const auto it = schema_.insert_table(typeid(Type), node);
|
const auto it = schema_.insert_table(typeid(Type), node);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue