enabled use of sql_logger in statement.cpp
This commit is contained in:
parent
621c3703fd
commit
b2d5db2702
|
|
@ -1,13 +1,12 @@
|
|||
#include "matador/sql/statement.hpp"
|
||||
#include "matador/sql/record.hpp"
|
||||
#include "matador/sql/field.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
namespace matador::sql {
|
||||
|
||||
statement::statement(const std::shared_ptr<statement_proxy>& proxy, logger_ptr logger)
|
||||
statement::statement(const std::shared_ptr<statement_proxy>& proxy, logger_ptr logger)
|
||||
: statement_proxy_(proxy)
|
||||
, bindings_(proxy->create_binder())
|
||||
, logger_(std::move(logger)){}
|
||||
|
|
@ -62,26 +61,25 @@ utils::result<query_result<record>, utils::error> statement::fetch() const {
|
|||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
// logger_.info(statement_->query_.sql);
|
||||
logger_->on_fetch(statement_proxy_->sql());
|
||||
const auto prototype = result.value()->prototype();
|
||||
return utils::ok(query_result<record>(std::move(*result), prototype));
|
||||
}
|
||||
|
||||
utils::result<std::optional<record>, utils::error> statement::fetch_one() const {
|
||||
// logger_.info(statement_->query_.sql);
|
||||
auto result = statement_proxy_->fetch(*bindings_);
|
||||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
auto result = statement_proxy_->fetch(*bindings_);
|
||||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
|
||||
const auto prototype = result.value()->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.release()});
|
||||
const auto prototype = result.value()->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});
|
||||
}
|
||||
logger_->on_fetch(statement_proxy_->sql());
|
||||
return utils::ok(std::optional{first.release()});
|
||||
}
|
||||
|
||||
void statement::reset() const {
|
||||
|
|
@ -101,8 +99,8 @@ utils::result<std::unique_ptr<query_result_impl>, utils::error> statement::fetch
|
|||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
logger_->on_fetch(statement_proxy_->sql());
|
||||
|
||||
// logger_.info(statement_->query_.sql);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue