started lazy loading
This commit is contained in:
parent
2fdbfc651e
commit
466977b620
|
|
@ -4,7 +4,7 @@
|
||||||
#include "matador/orm/query_builder_exception.hpp"
|
#include "matador/orm/query_builder_exception.hpp"
|
||||||
|
|
||||||
#include "matador/query/condition.hpp"
|
#include "matador/query/condition.hpp"
|
||||||
#include "matador/query/query_intermediates.hpp"
|
#include "matador/query/query.hpp"
|
||||||
|
|
||||||
#include "matador/sql/connection.hpp"
|
#include "matador/sql/connection.hpp"
|
||||||
|
|
||||||
|
|
@ -254,17 +254,18 @@ private:
|
||||||
|
|
||||||
template<class Pointer>
|
template<class Pointer>
|
||||||
void session_query_builder::on_foreign_object(const char *id, Pointer &, const utils::foreign_attributes &attr) {
|
void session_query_builder::on_foreign_object(const char *id, Pointer &, const utils::foreign_attributes &attr) {
|
||||||
if (attr.fetch() == utils::fetch_type::EAGER) {
|
|
||||||
const auto info = schema_.info<typename Pointer::value_type>();
|
const auto info = schema_.info<typename Pointer::value_type>();
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw query_builder_exception{query_build_error::UnknownType};
|
throw query_builder_exception{query_build_error::UnknownType};
|
||||||
}
|
}
|
||||||
|
const auto foreign_table = std::make_shared<sql::table>(info->get().name(), build_alias('t', ++table_index));
|
||||||
|
if (attr.fetch() == utils::fetch_type::EAGER) {
|
||||||
|
|
||||||
auto next = processed_tables_.find(info->get().name());
|
auto next = processed_tables_.find(info->get().name());
|
||||||
if (next != processed_tables_.end()) {
|
if (next != processed_tables_.end()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
table_info_stack_.push({info.value(), std::make_shared<sql::table>(info->get().name(), build_alias('t', ++table_index))});
|
table_info_stack_.push({info.value(), foreign_table});
|
||||||
next = processed_tables_.insert({info->get().name(), table_info_stack_.top().table}).first;
|
next = processed_tables_.insert({info->get().name(), table_info_stack_.top().table}).first;
|
||||||
typename Pointer::value_type obj;
|
typename Pointer::value_type obj;
|
||||||
access::process(*this, obj);
|
access::process(*this, obj);
|
||||||
|
|
@ -279,7 +280,14 @@ void session_query_builder::on_foreign_object(const char *id, Pointer &, const u
|
||||||
sql::column{next->second, pk->name()}
|
sql::column{next->second, pk->name()}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// using namespace matador::utils;
|
||||||
|
// using namespace matador::query;
|
||||||
push(id);
|
push(id);
|
||||||
|
// create select query
|
||||||
|
// const auto result = matador::query::query::select<typename Pointer::value_type>(schema_)
|
||||||
|
// .from(*foreign_table)
|
||||||
|
// .where(sql::column(foreign_table, id, "") == _)
|
||||||
|
// .prepare();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue