implemented lazy loading for object_ptr and belongs_to
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "matador/sql/statement.hpp"
|
||||
#include "matador/sql/record.hpp"
|
||||
#include "matador/sql/field.hpp"
|
||||
#include "matador/sql/query_record_result.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
@@ -64,9 +65,7 @@ utils::result<query_result<record>, utils::error> statement::fetch() const {
|
||||
}
|
||||
// logger_.info(statement_->query_.sql);
|
||||
const auto prototype = result.value()->prototype();
|
||||
return utils::ok(query_result<record>(std::move(*result), [prototype] {
|
||||
return detail::create_prototype<record>(prototype);
|
||||
}));
|
||||
return utils::ok(query_result<record>(std::move(*result), prototype));
|
||||
}
|
||||
|
||||
utils::result<std::optional<record>, utils::error> statement::fetch_one() const {
|
||||
@@ -77,15 +76,13 @@ utils::result<std::optional<record>, utils::error> statement::fetch_one() const
|
||||
}
|
||||
|
||||
const auto prototype = result.value()->prototype();
|
||||
query_result<record> records(std::move(*result), [prototype] {
|
||||
return sql::detail::create_prototype<record>(prototype);
|
||||
});
|
||||
query_result<record> records(std::move(*result), prototype);
|
||||
auto first = records.begin();
|
||||
if (first == records.end()) {
|
||||
return utils::ok(std::optional<record>{std::nullopt});
|
||||
}
|
||||
|
||||
return utils::ok(std::optional{*first.get()});
|
||||
return utils::ok(std::optional{first.release()});
|
||||
}
|
||||
|
||||
void statement::reset() const {
|
||||
|
||||
Reference in New Issue
Block a user