moved parameter_binder from member to parameter to bind, execute and fetch methods
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "matador/sql/query_context.hpp"
|
||||
#include "matador/sql/internal/query_result_impl.hpp"
|
||||
#include "matador/sql/interface/parameter_binder.hpp"
|
||||
#include "matador/sql/object_parameter_binder.hpp"
|
||||
|
||||
#include "matador/utils/data_type_traits.hpp"
|
||||
@@ -21,24 +22,23 @@ protected:
|
||||
public:
|
||||
virtual ~statement_impl() = default;
|
||||
|
||||
virtual utils::result<size_t, utils::error> execute() = 0;
|
||||
virtual utils::result<std::unique_ptr<query_result_impl>, utils::error> fetch() = 0;
|
||||
virtual utils::result<size_t, utils::error> execute(const interface::parameter_binder& bindings) = 0;
|
||||
virtual utils::result<std::unique_ptr<query_result_impl>, utils::error> fetch(const interface::parameter_binder& bindings) = 0;
|
||||
|
||||
template < class Type >
|
||||
void bind_object(Type &obj)
|
||||
{
|
||||
void bind_object(Type &obj, const interface::parameter_binder& bindings) {
|
||||
object_parameter_binder object_binder_;
|
||||
object_binder_.reset(start_index());
|
||||
object_binder_.bind(obj, binder());
|
||||
object_binder_.bind(obj, bindings);
|
||||
}
|
||||
|
||||
template < class Type >
|
||||
void bind(const size_t pos, Type &val) {
|
||||
utils::data_type_traits<Type>::bind_value(binder(), adjust_index(pos), val);
|
||||
void bind(const size_t pos, Type &val, const interface::parameter_binder& bindings) {
|
||||
utils::data_type_traits<Type>::bind_value(bindings, adjust_index(pos), val);
|
||||
}
|
||||
|
||||
void bind(size_t pos, const char *value, size_t size);
|
||||
void bind(size_t pos, std::string &val, size_t size);
|
||||
void bind(size_t pos, const char *value, size_t size, interface::parameter_binder& bindings) const;
|
||||
void bind(size_t pos, std::string &val, size_t size, interface::parameter_binder& bindings) const;
|
||||
|
||||
virtual void reset() = 0;
|
||||
|
||||
@@ -46,12 +46,13 @@ public:
|
||||
[[nodiscard]] bool is_valid_host_var(const std::string &host_var, size_t pos) const;
|
||||
|
||||
protected:
|
||||
virtual utils::attribute_writer& binder() = 0;
|
||||
[[nodiscard]] virtual size_t start_index() const;
|
||||
[[nodiscard]] virtual size_t adjust_index(size_t index) const;
|
||||
[[nodiscard]] virtual std::unique_ptr<utils::attribute_writer> create_binder() const = 0;
|
||||
|
||||
protected:
|
||||
friend class statement;
|
||||
friend class statement_proxy;
|
||||
|
||||
query_context query_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user