proxy lazy resolve progress

This commit is contained in:
Sascha Kühl 2025-08-25 16:00:32 +02:00
parent a4b35b913e
commit cce7f2c099
1 changed files with 18 additions and 0 deletions

View File

@ -32,10 +32,14 @@ struct session_context {
template<typename Type>
class lazy_object_resolver final : public object::object_resolver<Type> {
public:
explicit lazy_object_resolver(sql::statement &&stmt) : stmt_(std::move(stmt)) {}
Type* resolve(const object::object_proxy<Type>& proxy) const override {
return proxy.resolve();
}
private:
sql::statement stmt_;
};
class prototype_builder final {
@ -43,6 +47,15 @@ public:
explicit prototype_builder(const std::unordered_map<std::string, sql::statement> &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 >
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*/) {}
@ -50,6 +63,11 @@ public:
static void on_attribute(const char * /*id*/, Type &/*obj*/, const utils::field_attributes &/*attr*/ = utils::null_attributes) {}
template<class Pointer>
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>