fixed session tests

This commit is contained in:
Sascha Kühl
2025-10-08 16:03:00 +02:00
parent cb0f6322f4
commit 463647ba59
9 changed files with 144 additions and 91 deletions
+8 -2
View File
@@ -150,7 +150,10 @@ statement &statement::bind(const Type &obj) {
template<class Type>
utils::result<query_result<Type>, utils::error> statement::fetch() {
return statement_proxy_->fetch(*bindings_).and_then([](std::unique_ptr<query_result_impl> &&value) {
return utils::ok(query_result<Type>(std::forward<decltype(value)>(value)));
const auto prototype = value->prototype();
return utils::ok(query_result<Type>(std::forward<decltype(value)>(value), [prototype] {
return detail::create_prototype<Type>(prototype);
}));
});
}
@@ -160,7 +163,10 @@ utils::result<std::unique_ptr<Type>, utils::error> statement::fetch_one() {
if (!result.is_ok()) {
return utils::failure(result.err());
}
auto records = query_result<Type>(result.release());
const auto prototype = result.value()->prototype();
auto records = query_result<Type>(result.release(), [prototype] {
return detail::create_prototype<Type>(prototype);
});
auto first = records.begin();
if (first == records.end()) {
return utils::ok(std::unique_ptr<Type>{nullptr});