moved parameter_binder from member to parameter to bind, execute and fetch methods
This commit is contained in:
@@ -11,20 +11,47 @@ statement::statement(const std::shared_ptr<statement_proxy>& proxy, logger_ptr
|
||||
: statement_proxy_(proxy)
|
||||
, logger_(std::move(logger)){}
|
||||
|
||||
statement &statement::bind(const size_t pos, const char *value) {
|
||||
statement_proxy_->bind(pos, value, strlen(value));
|
||||
statement::statement(statement&& x) noexcept
|
||||
: statement_proxy_(std::move(x.statement_proxy_))
|
||||
, bindings_(std::move(x.bindings_))
|
||||
, logger_(std::move(x.logger_)) {
|
||||
}
|
||||
|
||||
statement& statement::operator=(statement&& x) noexcept {
|
||||
statement_proxy_ = std::move(x.statement_proxy_);
|
||||
bindings_ = std::move(x.bindings_);
|
||||
logger_ = std::move(x.logger_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
statement &statement::bind(const size_t pos, std::string &val, const size_t size)
|
||||
{
|
||||
statement_proxy_->bind(pos, val, size);
|
||||
statement::statement(const statement& x)
|
||||
: statement_proxy_(x.statement_proxy_)
|
||||
, bindings_(x.statement_proxy_->create_binder())
|
||||
, logger_(x.logger_) {
|
||||
}
|
||||
statement& statement::operator=(const statement& x) {
|
||||
if (&x == this) {
|
||||
return *this;
|
||||
}
|
||||
statement_proxy_ = x.statement_proxy_;
|
||||
bindings_ = x.statement_proxy_->create_binder();
|
||||
logger_ = x.logger_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
statement &statement::bind(const size_t pos, const char *value) {
|
||||
statement_proxy_->bind(pos, value, strlen(value), *bindings_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
statement &statement::bind(const size_t pos, std::string &val, const size_t size) {
|
||||
statement_proxy_->bind(pos, val, size, *bindings_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
utils::result<size_t, utils::error> statement::execute() const {
|
||||
// logger_.info(statement_->query_.sql);
|
||||
return statement_proxy_->execute();
|
||||
return statement_proxy_->execute(*bindings_);
|
||||
}
|
||||
|
||||
//bool is_unknown(const std::vector<object::column_definition> &columns) {
|
||||
@@ -39,7 +66,7 @@ utils::result<query_result<record>, utils::error> statement::fetch() const {
|
||||
// }
|
||||
|
||||
|
||||
auto result = statement_proxy_->fetch();
|
||||
auto result = statement_proxy_->fetch(*bindings_);
|
||||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
@@ -49,7 +76,7 @@ utils::result<query_result<record>, utils::error> statement::fetch() const {
|
||||
|
||||
utils::result<std::optional<record>, utils::error> statement::fetch_one() const {
|
||||
// logger_.info(statement_->query_.sql);
|
||||
auto result = statement_proxy_->fetch();
|
||||
auto result = statement_proxy_->fetch(*bindings_);
|
||||
if (!result.is_ok()) {
|
||||
return utils::failure(result.err());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user