set result_type in query_context to specify type
This commit is contained in:
parent
02d6ac514c
commit
1deaab116c
|
|
@ -164,6 +164,7 @@ statement &statement::bind(const Type &obj) {
|
||||||
template<class Type>
|
template<class Type>
|
||||||
utils::result<query_result<Type>, utils::error> statement::fetch() {
|
utils::result<query_result<Type>, utils::error> statement::fetch() {
|
||||||
std::cout << statement_proxy_->sql() << std::endl;
|
std::cout << statement_proxy_->sql() << std::endl;
|
||||||
|
statement_proxy_->statement_->query_.result_type = typeid(Type);
|
||||||
return statement_proxy_->fetch(*bindings_).and_then([this](std::unique_ptr<query_result_impl> &&value) {
|
return statement_proxy_->fetch(*bindings_).and_then([this](std::unique_ptr<query_result_impl> &&value) {
|
||||||
auto resolver = statement_proxy_->statement_->query_.resolver->object_resolver<Type>();
|
auto resolver = statement_proxy_->statement_->query_.resolver->object_resolver<Type>();
|
||||||
const auto prototype = value->prototype();
|
const auto prototype = value->prototype();
|
||||||
|
|
@ -176,6 +177,7 @@ utils::result<query_result<Type>, utils::error> statement::fetch() {
|
||||||
template<class Type>
|
template<class Type>
|
||||||
utils::result<object::object_ptr<Type>, utils::error> statement::fetch_one() {
|
utils::result<object::object_ptr<Type>, utils::error> statement::fetch_one() {
|
||||||
std::cout << statement_proxy_->sql() << std::endl;
|
std::cout << statement_proxy_->sql() << std::endl;
|
||||||
|
statement_proxy_->statement_->query_.result_type = typeid(Type);
|
||||||
auto result = statement_proxy_->fetch(*bindings_);
|
auto result = statement_proxy_->fetch(*bindings_);
|
||||||
if (!result.is_ok()) {
|
if (!result.is_ok()) {
|
||||||
return utils::failure(result.err());
|
return utils::failure(result.err());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue