implemented lazy loading for object_ptr and belongs_to

This commit is contained in:
2026-01-15 12:40:54 +01:00
parent db8e137c11
commit 7626331866
81 changed files with 1790 additions and 927 deletions
+4 -7
View File
@@ -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 {