proxy lazy resolve progress
This commit is contained in:
parent
a4b35b913e
commit
cce7f2c099
|
|
@ -32,10 +32,14 @@ struct session_context {
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
class lazy_object_resolver final : public object::object_resolver<Type> {
|
class lazy_object_resolver final : public object::object_resolver<Type> {
|
||||||
public:
|
public:
|
||||||
|
explicit lazy_object_resolver(sql::statement &&stmt) : stmt_(std::move(stmt)) {}
|
||||||
|
|
||||||
Type* resolve(const object::object_proxy<Type>& proxy) const override {
|
Type* resolve(const object::object_proxy<Type>& proxy) const override {
|
||||||
return proxy.resolve();
|
return proxy.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
sql::statement stmt_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class prototype_builder final {
|
class prototype_builder final {
|
||||||
|
|
@ -43,6 +47,15 @@ public:
|
||||||
explicit prototype_builder(const std::unordered_map<std::string, sql::statement> &statements_per_column)
|
explicit prototype_builder(const std::unordered_map<std::string, sql::statement> &statements_per_column)
|
||||||
: statements_per_column_(statements_per_column) {}
|
: statements_per_column_(statements_per_column) {}
|
||||||
|
|
||||||
|
|
||||||
|
template < typename Type >
|
||||||
|
Type build() const {
|
||||||
|
Type obj;
|
||||||
|
access::process(*this, obj);
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
template < class V >
|
template < class V >
|
||||||
static void on_primary_key(const char * /*id*/, V &/*pk*/, const utils::primary_key_attribute& /*attr*/ = utils::default_pk_attributes) {}
|
static void on_primary_key(const char * /*id*/, V &/*pk*/, const utils::primary_key_attribute& /*attr*/ = utils::default_pk_attributes) {}
|
||||||
static void on_revision(const char * /*id*/, unsigned long long &/*rev*/) {}
|
static void on_revision(const char * /*id*/, unsigned long long &/*rev*/) {}
|
||||||
|
|
@ -50,6 +63,11 @@ public:
|
||||||
static void on_attribute(const char * /*id*/, Type &/*obj*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
|
static void on_attribute(const char * /*id*/, Type &/*obj*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
|
||||||
template<class Pointer>
|
template<class Pointer>
|
||||||
void on_belongs_to(const char *id, Pointer &obj, const utils::foreign_attributes &attr) {
|
void on_belongs_to(const char *id, Pointer &obj, const utils::foreign_attributes &attr) {
|
||||||
|
const auto it = statements_per_column_.find(id);
|
||||||
|
if (it == statements_per_column_.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
template<class Pointer>
|
template<class Pointer>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue