session progress
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace matador::utils {
|
||||
class value;
|
||||
@@ -82,14 +84,14 @@ public:
|
||||
void on_attribute(const char *id, utils::value &val, 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)
|
||||
{
|
||||
void on_belongs_to(const char * /*id*/, Pointer &x, const utils::foreign_attributes &attr) {
|
||||
if (x.empty()) {
|
||||
x = new typename Pointer::value_type;
|
||||
}
|
||||
if (attr.fetch() == utils::fetch_type::LAZY) {
|
||||
pk_reader_.read(*x, column_index_++);
|
||||
} else {
|
||||
} else if (const auto ti = std::type_index(typeid(*x)); processed_types_.count(ti) == 0) {
|
||||
processed_types_.insert(ti);
|
||||
access::process(*this, *x);
|
||||
}
|
||||
}
|
||||
@@ -101,8 +103,8 @@ public:
|
||||
}
|
||||
if (attr.fetch() == utils::fetch_type::LAZY) {
|
||||
pk_reader_.read(*x, column_index_++);
|
||||
} else {
|
||||
access::process(*this, *x);
|
||||
} else if (const auto ti = std::type_index(typeid(*x)); processed_types_.count(ti) == 0) {
|
||||
processed_types_.insert(ti);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +116,8 @@ public:
|
||||
void on_has_many(const char * /*id*/, ContainerType &cont, const char * /*join_column*/, const utils::foreign_attributes &attr) {
|
||||
if ( attr.fetch() == utils::fetch_type::LAZY ) {
|
||||
// pk_reader_.read(*id, column_index_++);
|
||||
} else {
|
||||
} else if (const auto ti = std::type_index(typeid(typename ContainerType::value_type::value_type)); processed_types_.count(ti) == 0) {
|
||||
processed_types_.insert(ti);
|
||||
auto obj = std::make_unique<typename ContainerType::value_type::value_type>();
|
||||
// typename ContainerType::value_type x(new typename ContainerType::value_type::value_type);
|
||||
access::process(*this, *obj);
|
||||
@@ -145,6 +148,7 @@ public:
|
||||
if (!*fetched) {
|
||||
return false;
|
||||
}
|
||||
processed_types_.insert(typeid(Type));
|
||||
access::process(*this, obj);
|
||||
return true;
|
||||
}
|
||||
@@ -156,6 +160,7 @@ protected:
|
||||
std::vector<object::attribute_definition> prototype_;
|
||||
std::unique_ptr<query_result_reader> reader_;
|
||||
detail::pk_reader pk_reader_;
|
||||
std::unordered_set<std::type_index> processed_types_;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
Reference in New Issue
Block a user